diff --git a/projects/hip/.vimrc b/projects/hip/.vimrc deleted file mode 100644 index 019afa57e6..0000000000 --- a/projects/hip/.vimrc +++ /dev/null @@ -1 +0,0 @@ -:set makeprg=make\ -C\ build.hcc-LC.db diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 6f9a819c4d..eee1a14a8a 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -33,7 +33,7 @@ execute_process(COMMAND git show -s --format=@%ct OUTPUT_VARIABLE HIP_VERSION_PATCH OUTPUT_STRIP_TRAILING_WHITESPACE) -set(HIP_VERSION $HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH) +set(HIP_VERSION ${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}.${HIP_VERSION_PATCH}) add_to_config(_versionInfo HIP_VERSION_MAJOR) add_to_config(_versionInfo HIP_VERSION_MINOR) add_to_config(_versionInfo HIP_VERSION_PATCH) @@ -63,14 +63,16 @@ if(HIP_PLATFORM STREQUAL "hcc") set(HCC_HOME $ENV{HCC_HOME} CACHE PATH "Path to which HCC has been installed") endif() endif() + if(DEFINED ENV{HIP_DEVELOPER}) add_to_config(_buildInfo HCC_HOME) endif() if(IS_ABSOLUTE ${HCC_HOME} AND EXISTS ${HCC_HOME} AND IS_DIRECTORY ${HCC_HOME}) execute_process(COMMAND ${HCC_HOME}/bin/hcc --version - COMMAND cut -d\ -f9 OUTPUT_VARIABLE HCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE ".*based on HCC " "" HCC_VERSION ${HCC_VERSION}) + string(REGEX REPLACE " .*" "" HCC_VERSION ${HCC_VERSION}) message(STATUS "Looking for HCC in: " ${HCC_HOME} ". Found version: " ${HCC_VERSION}) else() message(FATAL_ERROR "Don't know where to find HCC. Please specify abolute path using -DHCC_HOME") @@ -78,6 +80,9 @@ if(HIP_PLATFORM STREQUAL "hcc") add_to_config(_buildInfo HCC_VERSION) string(REPLACE "-" ";" HCC_VERSION_LIST ${HCC_VERSION}) list(GET HCC_VERSION_LIST 0 HCC_PACKAGE_VERSION) + string(REPLACE "." ";" HCC_VERSION_LIST ${HCC_PACKAGE_VERSION}) + list(GET HCC_VERSION_LIST 0 HCC_VERSION_MAJOR) + list(GET HCC_VERSION_LIST 1 HCC_VERSION_MINOR) # Determine HSA_PATH if(NOT DEFINED HSA_PATH) @@ -137,7 +142,7 @@ add_to_config(_buildInfo COMPILE_HIP_ATP_MARKER) # Build steps ############################# # Rebuild cmake cache updates .hipInfo and .hipVersion -add_custom_target(update_build_and_version_info ALL COMMAND make rebuild_cache) +add_custom_target(update_build_and_version_info COMMAND make rebuild_cache) # Build clang hipify if enabled add_subdirectory(hipify-clang) @@ -155,7 +160,8 @@ if(HIP_PLATFORM STREQUAL "hcc") set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -DHIP_VERSION_MAJOR=${HIP_VERSION_MAJOR} -DHIP_VERSION_MINOR=${HIP_VERSION_MINOR} -DHIP_VERSION_PATCH=${HIP_VERSION_PATCH}") # Add remaining flags - set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include -I/usr/local/include/c++/v1 -stdlib=libc++") + execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --cxxflags OUTPUT_VARIABLE HCC_CXX_FLAGS) + set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC ${HCC_CXX_FLAGS} -I${HSA_PATH}/include") # Set compiler and compiler flags set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc") @@ -172,20 +178,36 @@ if(HIP_PLATFORM STREQUAL "hcc") src/hip_memory.cpp src/hip_peer.cpp src/hip_stream.cpp - src/hip_module.cpp) + src/hip_module.cpp + src/grid_launch.cpp + src/env.cpp) set(SOURCE_FILES_DEVICE src/device_util.cpp src/hip_ldg.cpp - src/hip_fp16.cpp) + src/hip_fp16.cpp + src/device_functions.cpp + src/math_functions.cpp) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic") + execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") + #find_package(LLVM HINTS ${HCC_HOME}/compiler/lib/cmake) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) + target_link_libraries(hip_hcc PRIVATE hc_am) + #target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) + target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) add_dependencies(hip_device hip_hcc) + string(REPLACE " " ";" HCC_CXX_FLAGS_LIST ${HCC_CXX_FLAGS}) + foreach(TARGET hip_hcc hip_hcc_static hip_device) + target_include_directories(${TARGET} SYSTEM INTERFACE $/include>;${HSA_PATH}/include) + endforeach() + target_link_libraries(hip_hcc INTERFACE hcc::hccrt;hcc::hc_am) + # Generate hcc_version.txt add_custom_target(query_hcc_version COMMAND ${HCC_HOME}/bin/hcc --version > ${PROJECT_BINARY_DIR}/hcc_version.tmp) add_custom_target(check_hcc_version COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/hcc_version.tmp ${PROJECT_BINARY_DIR}/hcc_version.txt DEPENDS query_hcc_version) @@ -210,7 +232,7 @@ add_custom_target(doc COMMAND HIP_PATH=${CMAKE_CURRENT_SOURCE_DIR} doxygen ${CMA # Install hip_hcc if platform is hcc if(HIP_PLATFORM STREQUAL "hcc") install(TARGETS hip_hcc_static hip_hcc hip_device DESTINATION lib) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_ir.ll DESTINATION lib) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_hc.ll ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_hc_gfx803.ll DESTINATION lib) # Install .hipInfo install(FILES ${PROJECT_BINARY_DIR}/.hipInfo DESTINATION lib) @@ -229,6 +251,39 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0) install(DIRECTORY cmake DESTINATION .) endif() +############################# +# hip-config +############################# +set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib) +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include) +set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) +set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip) + +if(HIP_PLATFORM STREQUAL "hcc") + install(TARGETS hip_hcc_static hip_hcc hip_device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR}) + install(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::) + include(CMakePackageConfigHelpers) + + configure_package_config_file( + hip-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/hip-config.cmake + INSTALL_DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} + PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR + ) + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/hip-config-version.cmake + VERSION "${HIP_VERSION}" + COMPATIBILITY SameMajorVersion + ) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/hip-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/hip-config-version.cmake + DESTINATION + ${CONFIG_PACKAGE_INSTALL_DIR} + ) +endif() + ############################# # Packaging steps ############################# @@ -268,7 +323,7 @@ add_custom_target(pkg_hip_hcc COMMAND ${CMAKE_COMMAND} . COMMAND cp *.rpm ${PROJECT_BINARY_DIR} COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${BUILD_DIR} - DEPENDS hip_hcc) + DEPENDS hip_hcc hip_device hip_hcc_static) # Package: hip_nvcc set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_nvcc) @@ -317,22 +372,28 @@ endif() # Testing steps ############################# # Target: test -set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hip_tests) -configure_file(tests/hip_tests.txt ${BUILD_DIR}/CMakeLists.txt @ONLY) -if(POLICY CMP0037) - cmake_policy(PUSH) - cmake_policy(SET CMP0037 OLD) +set(HIP_ROOT_DIR ${CMAKE_INSTALL_PREFIX}) +set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_ROOT_DIR}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET) +if(${RUN_HIT} EQUAL 0) + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_ROOT_DIR}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET) endif() -add_custom_target(install_for_test COMMAND "${CMAKE_COMMAND}" --build . --target install - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -execute_process(COMMAND getconf _NPROCESSORS_ONLN OUTPUT_VARIABLE DASH_JAY OUTPUT_STRIP_TRAILING_WHITESPACE) -add_custom_target(test COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} . - COMMAND make -j ${DASH_JAY} - COMMAND make test - WORKING_DIRECTORY ${BUILD_DIR} - DEPENDS install_for_test) -if(POLICY CMP0037) - cmake_policy(POP) +if(${RUN_HIT} EQUAL 0) + set(CMAKE_MODULE_PATH "${HIP_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH}) + include(${HIP_SRC_PATH}/tests/hit/HIT.cmake) + + # Add tests + include_directories(${HIP_SRC_PATH}/tests/src) + hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests") + + # Add top-level tests to build_tests + add_custom_target(build_tests DEPENDS directed_tests) + + # Add custom target: check + add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests) +else() + message(STATUS "Testing targets will not be available. To enable them please ensure that the HIP installation directory is writeable. Use -DCMAKE_INSTALL_PREFIX to specify a suitable location") endif() + # vim: ts=4:sw=4:expandtab:smartindent diff --git a/projects/hip/CONTRIBUTING.md b/projects/hip/CONTRIBUTING.md index f6ed47acef..d9d353681d 100644 --- a/projects/hip/CONTRIBUTING.md +++ b/projects/hip/CONTRIBUTING.md @@ -93,7 +93,7 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl ## Coding Guidelines (in brief) - Code Indentation: - Tabs should be expanded to spaces. - - Use 4 spaces indendation. + - Use 4 spaces indentation. - Capitalization and Naming - Prefer camelCase for HIP interfaces and internal symbols. Note HCC uses _ for separator. This guideline is not yet consistently followed in HIP code - eventual compliance is aspirational. @@ -120,13 +120,13 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl - HIP_INIT_API() should be placed at the start of each top-level HIP API. This function will make sure the HIP runtime is initialized, and also constructs an appropriate API string for tracing and CodeXL marker tracing. The arguments to HIP_INIT_API should match - those of the parent fucntion. + those of the parent function. - ihipLogStatus should only be called from top-level HIP APIs,and should be called to log and return the error code. The error code is used by the GetLastError and PeekLastError functions - if a HIP API simply returns, then the error will not be logged correctly. - All HIP environment variables should begin with the keyword HIP_ Environment variables should be long enough to describe their purpose but short enough so they can be remembered - perhaps 10-20 characters, with 3-4 parts separated by underscores. - To see the list of current environment variables, along with their values, set HIP_PRINT_ENV and run any hip applications on ROCM platform . + To see the list of current environment variables, along with their values, set HIP_PRINT_ENV and run any hip applications on ROCm platform . HIPCC or other tools may support additional environment variables which should follow the above convention. @@ -161,4 +161,4 @@ doxygen bug list. ## Other Tips: ### Markdown Editing -Recommended to use an offline Markown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable. +Recommended to use an offline Markdown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable. diff --git a/projects/hip/INSTALL.md b/projects/hip/INSTALL.md index 4139cb2010..ef584dafa0 100644 --- a/projects/hip/INSTALL.md +++ b/projects/hip/INSTALL.md @@ -22,14 +22,14 @@ HIP code can be developed either on AMD ROCm platform using hcc compiler, or a C ## AMD-hcc -* Install the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) packages. Rocm will install all of the necessary components, including the kernel driver, runtime software, HCC compiler, and HIP. +* Install the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) packages. ROCm will install all of the necessary components, including the kernel driver, runtime software, HCC compiler, and HIP. * Default paths and environment variables: * By default HIP looks for hcc in /opt/rocm/hcc (can be overridden by setting HCC_HOME environment variable) * By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable) * By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable). - * Optionally, consider adding /opt/rocm/bin to your path to make it easier to use the tools. + * Optionally, consider adding /opt/rocm/bin to your PATH to make it easier to use the tools. ## NVIDIA-nvcc @@ -96,7 +96,7 @@ The native GCN target is included with upstream LLVM, and has also been integrat Binary packages for the direct-to-isa package are included with the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) package. Alternatively, this sections describes how to build it from source: -1. Install the rocm packages as described above. +1. Install the ROCm packages as described above. 2. Follow the instructions [here](https://github.com/RadeonOpenCompute/HCC-Native-GCN-ISA/wiki) * In the make step for HCC, we recommend setting -DCMAKE_INSTALL_PREFIX. * Set HCC_HOME environment variable before compiling HIP program to point to the native compiler: diff --git a/projects/hip/README.md b/projects/hip/README.md index 83d041786e..f61c3b106a 100644 --- a/projects/hip/README.md +++ b/projects/hip/README.md @@ -88,8 +88,8 @@ The HIP Runtime API code and compute kernel definition can exist in the same sou ## HIP Portability and Compiler Technology HIP C++ code can be compiled with either : -- On the Nvidia CUDA platform, HIP provides header file which translate from the HIP runtime APIs to CUDA runtime APIs. The header file contains mostly inlined - functions and thus has very low overhead - developers coding in HIP should expect the same perforamnce as coding in native CUDA. The code is then +- On the NVIDIA CUDA platform, HIP provides header file which translate from the HIP runtime APIs to CUDA runtime APIs. The header file contains mostly inlined + functions and thus has very low overhead - developers coding in HIP should expect the same performance as coding in native CUDA. The code is then compiled with nvcc, the standard C++ compiler provided with the CUDA SDK. Developers can use any tools supported by the CUDA SDK including the CUDA profiler and debugger. - On the AMD ROCm platform, HIP provides a header and runtime library built on top of hcc compiler. The HIP runtime implements HIP streams, events, and memory APIs, @@ -120,7 +120,7 @@ make ## More Examples -The GitHub repot [HIP-Examples](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples.git) contains a hipified vesion of the popular Rodinia benchmark suite. +The GitHub repository [HIP-Examples](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples.git) contains a hipified version of the popular Rodinia benchmark suite. The README with the procedures and tips the team used during this porting effort is here: [Rodinia Porting Guide](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples/blob/master/rodinia_3.0/hip/README.hip_porting) ## Tour of the HIP Directories diff --git a/projects/hip/RELEASE.md b/projects/hip/RELEASE.md index a7c770f611..21fd8da7bb 100644 --- a/projects/hip/RELEASE.md +++ b/projects/hip/RELEASE.md @@ -3,7 +3,7 @@ We have attempted to document known bugs and limitations - in particular the [HIP Kernel Language](docs/markdown/hip_kernel_language.md) document uses the phrase "Under Development", and the [HIP Runtime API bug list](http://gpuopen-professionalcompute-tools.github.io/HIP/bug.html) lists known bugs. Upcoming: -- Stability: Enforce perioidic host synchronization to reclaim resources if the application has launched a large +- Stability: Enforce periodic host synchronization to reclaim resources if the application has launched a large number of commands (>1K) without synchronizing. - Register keyword now silently ignored on HCC (previously would emit warning). - Doc updates: Add some more frequently asked questions to FAQ, fix TOC in some files, review. @@ -13,6 +13,52 @@ Upcoming: ## Revision History: +=================================================================================================== +Release: 1.0.17102 +Date: 2017.03.07 +- Lots of improvements to hipify-clang. +- Added HIP package config for cmake. +- Several bug fixes and documentation updates. + + +=================================================================================================== +Release: 1.0.17066 +Date: 2017.02.11 +- Improved support for math device functions. +- Added several half math device functions. +- Enabled support for CUDA 8.0 in hipify-clang. +- Lots of bug fixes and documentation updates. + + +=================================================================================================== +Release: 1.0.17015 +Date: 2017.01.06 +- Several improvements to the hipify-clang infrastructure. +- Refactored module and function APIs. +- HIP now defaults to linking against the shared runtime library. +- Documentation updates. + + +=================================================================================================== +Release: 1.0.16502 +Date: 2016.12.13 +- Added several fast math and packaged math instrincs +- Improved debug and profiler documentation +- Support for building and linking to HIP shared library +- Several improvements to hipify-clang +- Several bug fixes + + +=================================================================================================== +Release: 1.0.16461 +Date: 2016.11.14 +- Significant changes to the HIP Profiling APIs. Refer to the documentation for details +- Improvements to P2P support +- New API: hipDeviceGetByPCIBusId +- Several bug fixes in NV path +- hipModuleLaunch now works for multi-dim kernels + + =================================================================================================== Release:1.0 Date: 2016.11.8 @@ -73,7 +119,7 @@ Date: 2016.04.25 - Create static library and link. - Set HIP_PATH to install. - Make hipDevice and hipStream thread-safe. - - Prefered hipStream usage is still to create new streams for each new thread, but it works even if you don;t. + - Preferred hipStream usage is still to create new streams for each new thread, but it works even if you don;t. - Improve automated platform detection: If AMD GPU is installed and detected by driver, default HIP_PLATFORM to hcc. - HIP_TRACE_API now prints arguments to the HIP function (in addition to name of function). - Deprecate hipDeviceGetProp (Replace with hipGetDeviceProp) diff --git a/projects/hip/bin/hccgenco.sh b/projects/hip/bin/hccgenco.sh index dcedfa174d..9d7f602911 100755 --- a/projects/hip/bin/hccgenco.sh +++ b/projects/hip/bin/hccgenco.sh @@ -10,7 +10,7 @@ if [ $# = 0 ]; then fi : ${ROCM_PATH:=/opt/rocm} -: ${ROCM_TARGET:=fiji} +: ${ROCM_TARGET:=gfx803} INPUT_FILES="" OUTPUT_FILE="" @@ -45,18 +45,17 @@ for inputfile in $INPUT_FILES; do done printf "\nint main(){}\n" >> $hipgenisa_main -$HIP_PATH/bin/hipcc $hipgenisa_files -o $hipgenisa_dir/a.out -mv dump.* $hipgenisa_dir -$ROCM_PATH/hcc-lc/bin/llvm-mc -arch=amdgcn -mcpu=$ROCM_TARGET -filetype=obj $hipgenisa_dir/dump.isa -o $hipgenisa_dir/dump.o -$ROCM_PATH/llvm/bin/clang -target amdgcn--amdhsa $hipgenisa_dir/dump.o -o $hipgenisa_dir/dump.co +$HIP_PATH/bin/hipcc -DGENERIC_GRID_LAUNCH=0 $hipgenisa_files -o $hipgenisa_dir/a.out +mv dump* $hipgenisa_dir +hsaco_file="dump-$ROCM_TARGET.hsaco" map_sym="" -kernels=$(objdump -t $hipgenisa_dir/dump.co | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) +kernels=$(objdump -t $hipgenisa_dir/$hsaco_file | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) for mangled_sym in $kernels; do - real_sym=$(c++filt $(c++filt _$mangled_sym | cut -d: -f3 | sed 's/_functor//g') | cut -d\( -f1) + real_sym=$(c++filt $(c++filt $mangled_sym | cut -d: -f3 | sed 's/_functor//g') | cut -d\( -f1) map_sym="--redefine-sym $mangled_sym=$real_sym $map_sym" done -objcopy -F elf64-little $map_sym $hipgenisa_dir/dump.co $OUTPUT_FILE +objcopy -F elf64-little $map_sym $hipgenisa_dir/$hsaco_file $OUTPUT_FILE rm $hipgenisa_files rm -r $hipgenisa_dir diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7d2675d0ba..bcd3e3a591 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -23,8 +23,8 @@ use File::Basename; # HSA_PATH : Path to HSA dir (default /opt/rocm/hsa). Used on AMD platforms only. if(scalar @ARGV == 0){ -print "No Arguments passed, exiting ...\n"; -exit(-1); + print "No Arguments passed, exiting ...\n"; + exit(-1); } #--- @@ -70,28 +70,40 @@ if ($verbose & 0x2) { # set if user explicitly requests -stdlib=libc++. (else we default to libstdc++ for better interop with g++): $setStdLib = 0; # TODO - set to 0 +$target_gfx701 = 0; +$target_gfx801 = 0; +$target_gfx802 = 0; +$target_gfx803 = 0; +$target_gfx900 = 0; + if ($HIP_PLATFORM eq "hcc") { $HSA_PATH=$ENV{'HSA_PATH'} // "/opt/rocm/hsa"; $HCC_HOME=$ENV{'HCC_HOME'} // $hipConfig{'HCC_HOME'} // "/opt/rocm/hcc"; - $HCC_VERSION=`${HCC_HOME}/bin/hcc --version | cut -d" " -f9 | tr -d "\n"`; - $HCC_VERSION_MAJOR=`${HCC_HOME}/bin/hcc --version | cut -d" " -f9 | cut -d"." -f1 | tr -d "\n"`; + $HCC_VERSION=`${HCC_HOME}/bin/hcc --version`; + $HCC_VERSION=~/.*based on HCC ([^ ]+).*/; + $HCC_VERSION=$1; + $HCC_VERSION_MAJOR=$HCC_VERSION; + $HCC_VERSION_MAJOR=~s/\..*//; $ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm"; $HIP_ATP_MARKER=$ENV{'HIP_ATP_MARKER'} // 1; $marker_path = "$ROCM_PATH/profiler/CXLActivityLogger"; - $ROCM_TARGET=$ENV{'ROCM_TARGET'} // "fiji"; + $ROCM_TARGET=$ENV{'ROCM_TARGET'} // "gfx803"; # HCC* may be used to compile src/hip_hcc.o (and also feed the HIPCXXFLAGS below) $HCC = "$HCC_HOME/bin/hcc"; - $HCCFLAGS = "-hc -I$HCC_HOME/include "; + $HCCFLAGS = "-hc -D__HIPCC__ -I$HCC_HOME/include "; $HIPCC=$HCC; $HIPCXXFLAGS = $HCCFLAGS; + $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; + + #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; if ($HCC_VERSION_MAJOR eq 1) { @@ -99,49 +111,33 @@ if ($HIP_PLATFORM eq "hcc") { my $GPP_CUR_VER = `g++ -dumpversion`; $GCC_CUR_VER =~ s/\R//g; $GPP_CUR_VER =~ s/\R//g; - if (${GCC_CUR_VER} eq ${GPP_CUR_VER}) { - $HCC_WA_FLAGS .= " -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} "; + + my @GPP_VER_FIELDS = split('\.', $GPP_CUR_VER); + + # Only include the libstdc++ headers and libraries flags explicitly if the g++ is older than version 5. + # That's because HCC already uses libstdc++ by default if a newer g++/libstdc++ is available + if (${GCC_CUR_VER} eq ${GPP_CUR_VER} and $GPP_VER_FIELDS[0] < 5) { + $HCC_WA_FLAGS .= " -stdlib=libstdc++ -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} "; + # Add C++ libs for GCC. + $HIPLDFLAGS .= " -lstdc++"; } } + # Force -stdlib=libc++ on UB14.04 + $HOST_OSNAME= `cat /etc/os-release | grep "^ID\=" | cut -d= -f2 | tr -d '\n'`; + $HOST_OSVER= `cat /etc/os-release | grep "^VERSION_ID\=" | cut -d= -f2 | tr -d '\n'`; + if ($HOST_OSNAME eq "ubuntu" and $HOST_OSVER eq "\"14.04\"") { + $HIPCXXFLAGS .= " -stdlib=libc++"; + $setStdLib = 1; + } + $HIPCXXFLAGS .= " -I$HIP_PATH/include/hip/hcc_detail/cuda"; $HIPCXXFLAGS .= " -I$HSA_PATH/include"; $HIPCXXFLAGS .= " -Wno-deprecated-register"; - $HIPLDFLAGS = "-hc -L$HCC_HOME/lib -Wl,--rpath=$HCC_HOME/lib -lc++ -ldl -lpthread -Wl,--whole-archive -lmcwamp -Wl,--no-whole-archive"; - # Suppress linker warnings in case HCC distribution contains OpenCL/SPIR symbols - $HOST_OSNAME= `cat /etc/os-release | grep "^ID\=" | cut -d= -f2 | tr -d '\n'`; - $HOST_OSVER= `cat /etc/os-release | grep "^VERSION_ID\=" | cut -d= -f2 | tr -d '\n'`; - if ($HOST_OSNAME eq "ubuntu" and $HOST_OSVER eq "\"16.04\"") { - # No additional flags required - } else { - $HIPLDFLAGS .= " -Wl,--defsym=_binary_kernel_spir_end=1 -Wl,--defsym=_binary_kernel_spir_start=1 -Wl,--defsym=_binary_kernel_cl_start=1 -Wl,--defsym=_binary_kernel_cl_end=1"; - } - if ($HOST_OSNAME eq "fedora") { - $HIPCXXFLAGS .= " -I/usr/local/include/c++/v1"; - } - - # Satisfy HCC dependencies - if ($HOST_OSNAME eq "fedora") { - $HIPLDFLAGS .= " -lc++abi"; - } else { - $HIPLDFLAGS .= " -lc++abi -lsupc++"; - } - $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; - - # Handle ROCm target platform - if ($ROCM_TARGET eq "fiji") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; - } - if ($ROCM_TARGET eq "carrizo") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:1"; - } - if ($ROCM_TARGET eq "hawaii") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:7:0:1"; - } - if ($ROCM_TARGET eq "polaris") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; - } + $HIPLDFLAGS .= " -lsupc++"; + $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt "; +# $HIPLDFLAGS .= " -L$HCC_HOME/compiler/lib -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMMC -lLLVMCore -lLLVMSupport "; # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. @@ -157,8 +153,6 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS .= " -L$marker_lib_path -lCXLActivityLogger -Wl,--rpath=$marker_lib_path"; } - # Add C++ libs for GCC. - $HIPLDFLAGS .= " -lstdc++"; $HIPLDFLAGS .= " -lm"; if ($verbose & 0x2) { @@ -193,7 +187,7 @@ my $needHipHcc = ($HIP_PLATFORM eq 'hcc'); # set if we need to link hip_hcc my $printHipVersion = 0; # print HIP version my $runCmd = 1; my $buildDeps = 0; -my $linkType = 0; +my $linkType = 1; my $setLinkType = 0; my @options = (); @@ -206,44 +200,47 @@ if ($verbose & 0x4) { # Handle code object generation my $ISACMD=""; if($HIP_PLATFORM eq "hcc"){ - $ISACMD .= "set ROCM_PATH=$ROCM_PATH && set ROCM_TARGET=$ROCM_TARGET && $HIP_PATH/bin/hccgenco.sh "; - if($ARGV[0] eq "--genco"){ - foreach $isaarg (@ARGV[1..$#ARGV]){ - $ISACMD .= " "; - $ISACMD .= $isaarg; + $ISACMD .= "set ROCM_PATH=$ROCM_PATH && set ROCM_TARGET=$ROCM_TARGET && $HIP_PATH/bin/hccgenco.sh "; + if($ARGV[0] eq "--genco"){ + foreach $isaarg (@ARGV[1..$#ARGV]){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + if ($verbose & 0x1) { + print "hipcc-cmd: ", $ISACMD, "\n"; + } + system($ISACMD) and die(); + exit(0); } - if ($verbose & 0x1) { - print "hipcc-cmd: ", $ISACMD, "\n"; - } - system($ISACMD) and die(); - exit(0); - } } -if(($HIP_PLATFORM eq "hcc") and defined $ENV{HIP_EXPERIMENTAL}){ +if(($HIP_PLATFORM eq "hcc")){ $EXPORT_LL=" "; - $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_ir.ll\n"; + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + $ENV{HIP_HC_IR_FILE}=""; } if($HIP_PLATFORM eq "nvcc"){ - $ISACMD .= "$HIP_PATH/bin/hipcc -ptx "; - if($ARGV[0] eq "--genco"){ - foreach $isaarg (@ARGV[1..$#ARGV]){ - $ISACMD .= " "; - $ISACMD .= $isaarg; + $ISACMD .= "$HIP_PATH/bin/hipcc -ptx "; + if($ARGV[0] eq "--genco"){ + foreach $isaarg (@ARGV[1..$#ARGV]){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + if ($verbose & 0x1) { + print "hipcc-cmd: ", $ISACMD, "\n"; + } + system($ISACMD) and die(); + exit(0); } - if ($verbose & 0x1) { - print "hipcc-cmd: ", $ISACMD, "\n"; - } - system($ISACMD) and die(); - exit(0); - } } my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool foreach $arg (@ARGV) { + $trimarg = $arg; + $trimarg =~ s/^\s+|\s+$//g; # Remive whitespace my $swallowArg = 0; if ($arg eq '-c') { $compileOnly = 1; @@ -254,38 +251,57 @@ foreach $arg (@ARGV) $needLDFLAGS = 1; } - if(($arg eq '-stdlib=libc++') and ($setStdLib eq 0)) + if(($trimarg eq '-stdlib=libc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= " -stdlib=libc++"; $setStdLib = 1; } - if(($arg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) + if($arg eq '--amdgpu-target=gfx701') + { + $target_gfx701 = 1; + } + if($arg eq '--amdgpu-target=gfx801') + { + $target_gfx801 = 1; + } + if($arg eq '--amdgpu-target=gfx802') + { + $target_gfx802 = 1; + } + if($arg eq '--amdgpu-target=gfx803') + { + $target_gfx803 = 1; + } + if($arg eq '--amdgpu-target=gfx900') + { + $target_gfx900 = 1; + } + + if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; $setStdLib = 1; } - if($arg eq '--version') { + if($trimarg eq '--version') { $printHipVersion = 1; } - if($arg eq '--short-version') { + if($trimarg eq '--short-version') { $printHipVersion = 1; $runCmd = 0; } - if($arg eq '-M') { + if($trimarg eq '-M') { $compileOnly = 1; $buildDeps = 1; } - if($arg eq '-use_fast_math') { - print "In fast Math"; + if($trimarg eq '-use_fast_math') { $HIPCXXFLAGS .= " -DHIP_FAST_MATH "; } - if(($arg eq '-use-staticlib') and ($setLinkType eq 0)) + if(($trimarg eq '-use-staticlib') and ($setLinkType eq 0)) { $linkType = 0; $setLinkType = 1; } - if(($arg eq '-use-sharedlib') and ($setLinkType eq 0)) + if(($trimarg eq '-use-sharedlib') and ($setLinkType eq 0)) { $linkType = 1; $setLinkType = 1; @@ -320,6 +336,64 @@ foreach $arg (@ARGV) } $toolArgs .= " $arg" unless $swallowArg; } +if(defined $ENV{HCC_AMDGPU_TARGET}) +{ + foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) + { + if($target eq 'gfx701') + { + $target_gfx701 = 1; + } + if($target eq 'gfx801') + { + $target_gfx801 = 1; + } + if($target eq 'gfx802') + { + $target_gfx802 = 1; + } + if($target eq 'gfx803') + { + $target_gfx803 = 1; + } + if($target eq 'gfx900') + { + $target_gfx900 = 1; + } + } +} +if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0 and $target_gfx900 eq 0) +{ + $target_gfx803 = 1; +} + +if($HIP_PLATFORM eq "hcc"){ + + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + + # Handle ROCm target platform + if ($target_gfx701 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx701"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX701__=1 "; + } + if ($target_gfx801 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX801__=1 "; + } + if ($target_gfx802 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX802__=1 "; + } + if ($target_gfx803 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX803__=1 "; + $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + if ($target_gfx900 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx900"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX900__=1 "; + } +} if ($hasC and $HIP_PLATFORM eq 'nvcc') { $HIPCXXFLAGS .= " -x cu"; @@ -333,15 +407,14 @@ if ($buildDeps and $HIP_PLATFORM eq 'nvcc') { if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc') { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; } if ($needHipHcc) { if ($linkType eq 0) { - substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -lhip_hcc_static -lhip_device " ; + substr($HIPLDFLAGS,0,0) = " $HIP_PATH/lib/libhip_hcc_static.a $HIP_PATH/lib/libhip_device.a " ; } else { - substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -Wl,--rpath=$HIP_PATH/lib -lhip_hcc -lhip_device "; + substr($HIPLDFLAGS,0,0) = " -Wl,--rpath=$HIP_PATH/lib $HIP_PATH/lib/libhip_hcc.so $HIP_PATH/lib/libhip_device.a "; } } @@ -373,7 +446,10 @@ if ($printHipVersion) { } if ($runCmd) { if ($HIP_PLATFORM eq "hcc" and exists($hipConfig{'HCC_VERSION'}) and $HCC_VERSION ne $hipConfig{'HCC_VERSION'}) { - print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") && die (); + print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") ; + die unless $ENV{'HIP_IGNORE_HCC_VERSION'}; } system ("$CMD") and die (); } + +# vim: ts=4:sw=4:expandtab:smartindent diff --git a/projects/hip/bin/hipcc_cmake_linker_helper b/projects/hip/bin/hipcc_cmake_linker_helper new file mode 100755 index 0000000000..bd4f6c118d --- /dev/null +++ b/projects/hip/bin/hipcc_cmake_linker_helper @@ -0,0 +1,5 @@ +#!/bin/bash + +SOURCE="${BASH_SOURCE[0]}" +HIP_PATH="$( command cd -P "$( dirname "$SOURCE" )/.." && pwd )" +HCC_HOME=$1 $HIP_PATH/bin/hipcc "${@:2}" diff --git a/projects/hip/bin/hipconvertinplace-perl.sh b/projects/hip/bin/hipconvertinplace-perl.sh new file mode 100755 index 0000000000..a8c8d6d9e8 --- /dev/null +++ b/projects/hip/bin/hipconvertinplace-perl.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +#usage : hipconvertinplace.sh [DIRNAME] [HIPIFY_OPTIONS] + +#hipify "inplace" all code files in specified directory. +# This can be quite handy when dealing with an existing CUDA code base since the script +# preserves the existing directory structure. + +# For each code file, this script will: +# - If ".prehip file does not exist, copy the original code to a new file with extension ".prehip". Then Hipify the code file. +# - If ".prehip" file exists, this is used as input to hipify. +# (this is useful for testing improvements to the hipify toolset). + + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 +shift +$SCRIPT_DIR/hipify -inplace -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` diff --git a/projects/hip/bin/hipconvertinplace.sh b/projects/hip/bin/hipconvertinplace.sh index a8c8d6d9e8..a765ab39fa 100755 --- a/projects/hip/bin/hipconvertinplace.sh +++ b/projects/hip/bin/hipconvertinplace.sh @@ -1,18 +1,24 @@ #!/bin/bash -#usage : hipconvertinplace.sh [DIRNAME] [HIPIFY_OPTIONS] +#usage : hipconvertinplace.sh DIRNAME [hipify options] [--] [clang options] -#hipify "inplace" all code files in specified directory. +#hipify "inplace" all code files in specified directory. # This can be quite handy when dealing with an existing CUDA code base since the script # preserves the existing directory structure. -# For each code file, this script will: -# - If ".prehip file does not exist, copy the original code to a new file with extension ".prehip". Then Hipify the code file. -# - If ".prehip" file exists, this is used as input to hipify. -# (this is useful for testing improvements to the hipify toolset). - - SCRIPT_DIR=`dirname $0` SEARCH_DIR=$1 -shift -$SCRIPT_DIR/hipify -inplace -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -inplace -print-stats $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/bin/hipexamine-perl.sh b/projects/hip/bin/hipexamine-perl.sh new file mode 100755 index 0000000000..40c1bf466d --- /dev/null +++ b/projects/hip/bin/hipexamine-perl.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#usage : hipexamine.sh DIRNAME [hipify.pl options] + +# Generate HIP stats (LOC, CUDA->API conversions, missing functionality) for all the code files +# in the specified directory. + + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 +shift +$SCRIPT_DIR/hipify -no-output -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` diff --git a/projects/hip/bin/hipexamine.sh b/projects/hip/bin/hipexamine.sh index 40c1bf466d..2a6fab7110 100755 --- a/projects/hip/bin/hipexamine.sh +++ b/projects/hip/bin/hipexamine.sh @@ -1,12 +1,22 @@ #!/bin/bash -#usage : hipexamine.sh DIRNAME [hipify.pl options] - -# Generate HIP stats (LOC, CUDA->API conversions, missing functionality) for all the code files -# in the specified directory. +#usage : hipexamine2.sh DIRNAME [hipify options] [--] [clang options] +# Generate CUDA->HIP conversion statistics for all the code files in the specified directory. SCRIPT_DIR=`dirname $0` SEARCH_DIR=$1 -shift -$SCRIPT_DIR/hipify -no-output -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -examine $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/cmake/FindHIP.cmake b/projects/hip/cmake/FindHIP.cmake index 5e17af72a5..5a5813ba0d 100644 --- a/projects/hip/cmake/FindHIP.cmake +++ b/projects/hip/cmake/FindHIP.cmake @@ -105,6 +105,25 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) endif() mark_as_advanced(HIP_HIPCONFIG_EXECUTABLE) + # Find HIPCC_CMAKE_LINKER_HELPER executable + find_program( + HIP_HIPCC_CMAKE_LINKER_HELPER + NAMES hipcc_cmake_linker_helper + PATHS + "${HIP_ROOT_DIR}" + ENV ROCM_PATH + ENV HIP_PATH + /opt/rocm + /opt/rocm/hip + PATH_SUFFIXES bin + NO_DEFAULT_PATH + ) + if(NOT HIP_HIPCC_CMAKE_LINKER_HELPER) + # Now search in default paths + find_program(HIP_HIPCC_CMAKE_LINKER_HELPER hipcc_cmake_linker_helper) + endif() + mark_as_advanced(HIP_HIPCC_CMAKE_LINKER_HELPER) + if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_VERSION) # Compute the version execute_process( @@ -178,6 +197,21 @@ hip_find_helper_file(run_make2cmake cmake) hip_find_helper_file(run_hipcc cmake) ############################################################################### +############################################################################### +# MACRO: Reset compiler flags +############################################################################### +macro(HIP_RESET_FLAGS) + unset(HIP_HIPCC_FLAGS) + unset(HIP_HCC_FLAGS) + unset(HIP_NVCC_FLAGS) + foreach(config ${_hip_configuration_types}) + string(TOUPPER ${config} config_upper) + unset(HIP_HIPCC_FLAGS_${config_upper}) + unset(HIP_HCC_FLAGS_${config_upper}) + unset(HIP_NVCC_FLAGS_${config_upper}) + endforeach() +endmacro() + ############################################################################### # MACRO: Separate the options from the sources ############################################################################### @@ -480,8 +514,13 @@ macro(HIP_ADD_EXECUTABLE hip_target) # Separate the sources from the options HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _nvcc_options ${ARGN}) HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) - list(REMOVE_ITEM _sources ${_source_files}) - set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_EXECUTABLE} -o ") + if(_source_files) + list(REMOVE_ITEM _sources ${_source_files}) + endif() + if("x${HCC_HOME}" STREQUAL "x") + set(HCC_HOME "/opt/rocm/hcc") + endif() + set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} -o ") add_executable(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE HIP) endmacro() @@ -493,7 +532,9 @@ macro(HIP_ADD_LIBRARY hip_target) # Separate the sources from the options HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _nvcc_options ${ARGN}) HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} ${_cmake_options} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) - list(REMOVE_ITEM _sources ${_source_files}) + if(_source_files) + list(REMOVE_ITEM _sources ${_source_files}) + endif() add_library(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE ${HIP_C_OR_CXX}) endmacro() diff --git a/projects/hip/cmake/FindHIP/run_hipcc.cmake b/projects/hip/cmake/FindHIP/run_hipcc.cmake index 6027cb9b0d..4dc2572e98 100644 --- a/projects/hip/cmake/FindHIP/run_hipcc.cmake +++ b/projects/hip/cmake/FindHIP/run_hipcc.cmake @@ -26,6 +26,7 @@ set(HIP_HIPCONFIG_EXECUTABLE "@HIP_HIPCONFIG_EXECUTABLE@") #path set(HIP_HOST_COMPILER "@HIP_HOST_COMPILER@") # path set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path set(HIP_run_make2cmake "@HIP_run_make2cmake@") # path +set(HCC_HOME "@HCC_HOME@") #path @HIP_HOST_FLAGS@ @_HIP_HIPCC_FLAGS@ @@ -42,6 +43,9 @@ execute_process(COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform OUTPUT_VARIABLE H if(NOT host_flag) set(__CC ${HIP_HIPCC_EXECUTABLE}) if(HIP_PLATFORM STREQUAL "hcc") + if(NOT "x${HCC_HOME}" STREQUAL "x") + set(ENV{HCC_HOME} ${HCC_HOME}) + endif() set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_HCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_HCC_FLAGS_${build_configuration}}) else() set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_NVCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_NVCC_FLAGS_${build_configuration}}) diff --git a/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md new file mode 100644 index 0000000000..3434d29a70 --- /dev/null +++ b/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md @@ -0,0 +1,499 @@ +# CUDA Driver API functions supported by HIP + +## **1. Data types used by CUDA driver** + +| **type** | **CUDA** | **HIP** | **CUDA description** | +|-------------:|---------------------------------------------------------------|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| struct | `CUDA_ARRAY3D_DESCRIPTOR` | | | +| struct | `CUDA_ARRAY_DESCRIPTOR` | | | +| struct | `CUDA_MEMCPY2D` | | | +| struct | `CUDA_MEMCPY3D` | | | +| struct | `CUDA_MEMCPY3D_PEER` | | | +| struct | `CUDA_POINTER_ATTRIBUTE_P2P_TOKENS` | | | +| struct | `CUDA_RESOURCE_DESC` | | | +| struct | `CUDA_RESOURCE_VIEW_DESC` | | | +| struct | `CUdevprop` | `hipDeviceProp_t` | | +| struct | `CUipcEventHandle` | | | +| struct | `CUipcMemHandle` | | | +| enum |***`CUaddress_mode`*** | | Texture reference addressing modes | +| 0 |*`CU_TR_ADDRESS_MODE_WRAP`* | | Wrapping address mode | +| 1 |*`CU_TR_ADDRESS_MODE_CLAMP`* | | Clamp to edge address mode | +| 2 |*`CU_TR_ADDRESS_MODE_MIRROR`* | | Mirror address mode | +| 3 |*`CU_TR_ADDRESS_MODE_BORDER`* | | Border address mode | +| enum |***`CUarray_cubemap_face`*** | | Array indices for cube faces | +| 0x00 |*`CU_CUBEMAP_FACE_POSITIVE_X`* | | Positive X face of cubemap | +| 0x01 |*`CU_CUBEMAP_FACE_NEGATIVE_X`* | | Negative X face of cubemap | +| 0x02 |*`CU_CUBEMAP_FACE_POSITIVE_Y`* | | Positive Y face of cubemap | +| 0x03 |*`CU_CUBEMAP_FACE_NEGATIVE_Y`* | | Negative Y face of cubemap | +| 0x04 |*`CU_CUBEMAP_FACE_POSITIVE_Z`* | | Positive Z face of cubemap | +| 0x05 |*`CU_CUBEMAP_FACE_NEGATIVE_Z`* | | Negative Z face of cubemap | +| enum |***`CUarray_format`*** | | Array formats | +| 0x01 |*`CU_AD_FORMAT_UNSIGNED_INT8`* | | Unsigned 8-bit integers | +| 0x02 |*`CU_AD_FORMAT_UNSIGNED_INT16`* | | Unsigned 16-bit integers | +| 0x03 |*`CU_AD_FORMAT_UNSIGNED_INT32`* | | Unsigned 32-bit integers | +| 0x08 |*`CU_AD_FORMAT_SIGNED_INT8`* | | Signed 8-bit integers | +| 0x09 |*`CU_AD_FORMAT_SIGNED_INT16`* | | Signed 16-bit integers | +| 0x0a |*`CU_AD_FORMAT_SIGNED_INT32`* | | Signed 32-bit integers | +| 0x10 |*`CU_AD_FORMAT_HALF`* | | 16-bit floating point | +| 0x20 |*`CU_AD_FORMAT_FLOAT`* | | 32-bit floating point | +| enum |***`CUctx_flags`*** | | Context creation flags | +| 0x00 |*`CU_CTX_SCHED_AUTO`* | | Automatic scheduling | +| 0x01 |*`CU_CTX_SCHED_SPIN`* | | Set spin as default scheduling | +| 0x02 |*`CU_CTX_SCHED_YIELD`* | | Set yield as default scheduling | +| 0x04 |*`CU_CTX_SCHED_BLOCKING_SYNC`* | | Set blocking synchronization as default scheduling | +| 0x04 |*`CU_CTX_BLOCKING_SYNC`* | | Set blocking synchronization as default scheduling Deprecated. This flag was deprecated as of CUDA 4.0 and was replaced with CU_CTX_SCHED_BLOCKING_SYNC.| +| 0x07 |*`CU_CTX_SCHED_MASK`* | | | +| 0x08 |*`CU_CTX_MAP_HOST`* | | Support mapped pinned allocations | +| 0x10 |*`CU_CTX_LMEM_RESIZE_TO_MAX`* | | Keep local memory allocation after launch | +| 0x1f |*`CU_CTX_FLAGS_MASK`* | | | +| enum |***`CUdevice_attribute`*** | | Device properties | +| 1 |*`CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK`* |*`hipDeviceAttributeMaxThreadsPerBlock`* | Maximum number of threads per block | +| 2 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X`* |*`hipDeviceAttributeMaxBlockDimX`* | Maximum block dimension X | +| 3 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y`* |*`hipDeviceAttributeMaxBlockDimY`* | Maximum block dimension Y | +| 4 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z`* |*`hipDeviceAttributeMaxBlockDimZ`* | Maximum block dimension Z | +| 5 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X`* |*`hipDeviceAttributeMaxGridDimX`* | Maximum grid dimension X | +| 6 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y`* |*`hipDeviceAttributeMaxGridDimY`* | Maximum grid dimension Y | +| 7 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z`* |*`hipDeviceAttributeMaxGridDimZ`* | Maximum grid dimension Y | +| 8 |*`CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Maximum shared memory available per block in bytes | +| 8 |*`CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK | +| 9 |*`CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY`* |*`hipDeviceAttributeTotalConstantMemory`* | Memory available on device for __constant__ variables in a CUDA C kernel in bytes | +| 10 |*`CU_DEVICE_ATTRIBUTE_WARP_SIZE`* |*`hipDeviceAttributeWarpSize`* | Warp size in threads | +| 11 |*`CU_DEVICE_ATTRIBUTE_MAX_PITCH`* | | Maximum pitch in bytes allowed by memory copies | +| 12 |*`CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Maximum number of 32-bit registers available per block | +| 12 |*`CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK | +| 13 |*`CU_DEVICE_ATTRIBUTE_CLOCK_RATE`* |*`hipDeviceAttributeClockRate`* | Typical clock frequency in kilohertz | +| 14 |*`CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT`* | | Alignment requirement for textures | +| 15 |*`CU_DEVICE_ATTRIBUTE_GPU_OVERLAP`* | | Device can possibly copy memory and execute a kernel concurrently. Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT| +| 16 |*`CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT`* |*`hipDeviceAttributeMultiprocessorCount`* | Number of multiprocessors on device | +| 17 |*`CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT`* | | Specifies whether there is a run time limit on kernels | +| 18 |*`CU_DEVICE_ATTRIBUTE_INTEGRATED`* | | Device is integrated with host memory | +| 19 |*`CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY`* | | Device can map host memory into CUDA address space | +| 20 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_MODE`* |*`hipDeviceAttributeComputeMode`* | Compute mode (See CUcomputemode for details) | +| 21 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH`* | | Maximum 1D texture width | +| 22 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH`* | | Maximum 2D texture width | +| 23 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT`* | | Maximum 2D texture height | +| 24 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH`* | | Maximum 3D texture width | +| 25 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT`* | | Maximum 3D texture height | +| 26 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH`* | | Maximum 3D texture depth | +| 27 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH`* | | Maximum 2D layered texture width | +| 28 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT`* | | Maximum 2D layered texture height | +| 29 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS`* | | Maximum layers in a 2D layered texture | +| 27 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH | +| 28 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT | +| 29 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS | +| 30 |*`CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT`* | | Alignment requirement for surfaces | +| 31 |*`CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS`* |*`hipDeviceAttributeConcurrentKernels`* | Device can possibly execute multiple kernels concurrently | +| 32 |*`CU_DEVICE_ATTRIBUTE_ECC_ENABLED`* | | Device has ECC support enabled | +| 33 |*`CU_DEVICE_ATTRIBUTE_PCI_BUS_ID`* |*`hipDeviceAttributePciBusId`* | PCI bus ID of the device | +| 34 |*`CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID`* |*`hipDeviceAttributePciDeviceId`* | PCI device ID of the device | +| 35 |*`CU_DEVICE_ATTRIBUTE_TCC_DRIVER`* | | Device is using TCC driver model | +| 36 |*`CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE`* |*`hipDeviceAttributeMemoryClockRate`* | Peak memory clock frequency in kilohertz | +| 37 |*`CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH`* |*`hipDeviceAttributeMemoryBusWidth`* | Global memory bus width in bits | +| 38 |*`CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE`* |*`hipDeviceAttributeL2CacheSize`* | Size of L2 cache in bytes | +| 39 |*`CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR`* |*`hipDeviceAttributeMaxThreadsPerMultiProcessor`* | Maximum resident threads per multiprocessor | +| 40 |*`CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT`* | | Number of asynchronous engines | +| 41 |*`CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING`* | | Device shares a unified address space with the host | +| 42 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH`* | | Maximum 1D layered texture width | +| 43 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS`* | | Maximum layers in a 1D layered texture | +| 44 |*`CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER`* | | Deprecated, do not use | +| 45 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH`* | | Maximum 2D texture width if CUDA_ARRAY3D_TEXTURE_GATHER is set | +| 46 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT`* | | Maximum 2D texture height if CUDA_ARRAY3D_TEXTURE_GATHER is set | +| 47 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE`* | | Alternate maximum 3D texture width | +| 48 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE`* | | Alternate maximum 3D texture height | +| 49 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE`* | | Alternate maximum 3D texture depth | +| 50 |*`CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID`* | | PCI domain ID of the device | +| 51 |*`CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT`* | | Pitch alignment requirement for textures | +| 52 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH`* | | Maximum cubemap texture width/height | +| 53 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH`* | | Maximum cubemap layered texture width/height | +| 54 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS`* | | Maximum layers in a cubemap layered texture | +| 55 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH`* | | Maximum 1D surface width | +| 56 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH`* | | Maximum 2D surface width | +| 57 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT`* | | Maximum 2D surface height | +| 58 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH`* | | Maximum 3D surface width | +| 59 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT`* | | Maximum 3D surface height | +| 60 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH`* | | Maximum 3D surface depth | +| 61 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH`* | | Maximum 1D layered surface width | +| 62 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS`* | | Maximum layers in a 1D layered surface | +| 63 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH`* | | Maximum 2D layered surface width | +| 64 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT`* | | Maximum 2D layered surface height | +| 65 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS`* | | Maximum layers in a 2D layered surface | +| 66 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH`* | | Maximum cubemap surface width | +| 67 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH`* | | Maximum cubemap layered surface width | +| 68 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS`* | | Maximum layers in a cubemap layered surface | +| 69 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH`* | | Maximum 1D linear texture width | +| 70 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH`* | | Maximum 2D linear texture width | +| 71 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT`* | | Maximum 2D linear texture height | +| 72 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH`* | | Maximum 2D linear texture pitch in bytes | +| 73 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH`* | | Maximum mipmapped 2D texture width | +| 74 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT`* | | Maximum mipmapped 2D texture height | +| 75 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR`* |*`hipDeviceAttributeComputeCapabilityMajor`* | Major compute capability version number | +| 76 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR`* |*`hipDeviceAttributeComputeCapabilityMinor`* | Minor compute capability version number | +| 77 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH`* | | Maximum mipmapped 1D texture width | +| 78 |*`CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED`* | | Device supports stream priorities | +| 79 |*`CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED`* | | Device supports caching globals in L1 | +| 80 |*`CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED`* | | Device supports caching locals in L1 | +| 81 |*`CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`* |*`hipDeviceAttributeMaxSharedMemoryPerMultiprocessor`* | Maximum shared memory available per multiprocessor in bytes | +| 82 |*`CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR`* | | Maximum number of 32-bit registers available per multiprocessor | +| 83 |*`CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY`* |*`hipDeviceAttributeManagedMemory`* | Device can allocate managed memory on this system | +| 84 |*`CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD`* | | Device is on a multi-GPU board | +| 85 |*`CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID`* | | Unique id for a group of devices on the same multi-GPU board | +| 86 |*`CU_DEVICE_ATTRIBUTE_MAX`* | | | +| enum |***`CUevent_flags`*** | | Event creation flags | +| 0x00 |*`CU_EVENT_DEFAULT`* |*`hipEventDefault`* | Default event flag | +| 0x01 |*`CU_EVENT_BLOCKING_SYNC`* |*`hipEventBlockingSync`* | Event uses blocking synchronization | +| 0x02 |*`CU_EVENT_DISABLE_TIMING`* |*`hipEventDisableTiming`* | Event will not record timing data | +| 0x04 |*`CU_EVENT_INTERPROCESS`* |*`hipEventInterprocess`* | Event is suitable for interprocess use. CU_EVENT_DISABLE_TIMING must be set | +| enum |***`CUfilter_mode`*** |***`hipTextureFilterMode`*** | Texture reference filtering modes | +| 0 |*`CU_TR_FILTER_MODE_POINT`* |*`hipFilterModePoint`* | Point filter mode | +| 1 |*`CU_TR_FILTER_MODE_LINEAR`* |*`hipFilterModeLinear`* | Linear filter mode | +| enum |***`CUfunc_cache`*** |***`hipFuncCache`*** | Function cache configurations | +| 0x00 |*`CU_FUNC_CACHE_PREFER_NONE`* |*`hipFuncCachePreferNone`* | no preference for shared memory or L1 (default) | +| 0x01 |*`CU_FUNC_CACHE_PREFER_SHARED`* |*`hipFuncCachePreferShared`* | prefer larger shared memory and smaller L1 cache | +| 0x02 |*`CU_FUNC_CACHE_PREFER_L1`* |*`hipFuncCachePreferL1`* | prefer larger L1 cache and smaller shared memory | +| 0x03 |*`CU_FUNC_CACHE_PREFER_EQUAL`* |*`hipFuncCachePreferEqual`* | prefer equal sized L1 cache and shared memory | +| enum |***`CUfunction_attribute`*** | | Function properties | +| 0 |*`CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK`* | | The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the function and the device on which the function is currently loaded. | +| 1 |*`CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`* | | The size in bytes of statically-allocated shared memory required by this function. This does not include dynamically-allocated shared memory requested by the user at runtime. | +| 2 |*`CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES`* | | The size in bytes of user-allocated constant memory required by this function. | +| 3 |*`CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES`* | | The size in bytes of local memory used by each thread of this function. | +| 4 |*`CU_FUNC_ATTRIBUTE_NUM_REGS`* | | The number of registers used by each thread of this function. | +| 5 |*`CU_FUNC_ATTRIBUTE_PTX_VERSION`* | | The PTX virtual architecture version for which the function was compiled. This value is the major PTX version * 10 + the minor PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value of 0 for cubins compiled prior to CUDA 3.0. | +| 6 |*`CU_FUNC_ATTRIBUTE_BINARY_VERSION`* | | The binary architecture version for which the function was compiled. This value is the major binary version * 10 + the minor binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy cubins that do not have a properly-encoded binary architecture version. | +| 7 |*`CU_FUNC_ATTRIBUTE_CACHE_MODE_CA`* | | The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set. | +| 8 |*`CU_FUNC_ATTRIBUTE_MAX`* | | | +| enum |***`CUgraphicsMapResourceFlags`*** | | Flags for mapping and unmapping interop resources | +| 0x00 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE`* | | | +| 0x01 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY`* | | | +| 0x02 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD`* | | | +| enum |***`CUgraphicsRegisterFlags`*** | | Flags to register a graphics resource | +| 0x00 |*`CU_GRAPHICS_REGISTER_FLAGS_NONE`* | | | +| 0x01 |*`CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY`* | | | +| 0x02 |*`CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD`* | | | +| 0x04 |*`CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST`* | | | +| 0x08 |*`CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER`* | | | +| enum |***`CUipcMem_flags`*** | | CUDA Ipc Mem Flags | +| 0x1 |*`CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS`* |*`hipIpcMemLazyEnablePeerAccess`* | Automatically enable peer access between remote devices as needed | +| enum |***`CUjit_cacheMode`*** | | Caching modes for dlcm | +| 0 |*`CU_JIT_CACHE_OPTION_NONE`* | | Compile with no -dlcm flag specified | +| |*`CU_JIT_CACHE_OPTION_CG`* | | Compile with L1 cache disabled | +| |*`CU_JIT_CACHE_OPTION_CA`* | | Compile with L1 cache enabled | +| enum |***`CUjit_fallback`*** | | Cubin matching fallback strategies | +| 0 |*`CU_PREFER_PTX`* | | Prefer to compile ptx if exact binary match not found | +| |*`CU_PREFER_BINARY`* | | Prefer to fall back to compatible binary code if exact match not found | +| enum |***`CUjit_option`*** | | Online compiler and linker options | +| 0 |*`CU_JIT_MAX_REGISTERS`* | | Max number of registers that a thread may use. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_THREADS_PER_BLOCK`* | | IN: Specifies minimum number of threads per block to target compilation for OUT: Returns the number of threads the compiler actually targeted. This restricts the resource utilization fo the compiler (e.g. max registers) such that a block with the given number of threads should be able to launch based on register limitations. Note, this option does not currently take into account any other resource limitations, such as shared memory utilization. Cannot be combined with CU_JIT_TARGET. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_WALL_TIME`* | | Overwrites the option value with the total wall clock time, in milliseconds, spent in the compiler and linker Option type: float Applies to: compiler and linker. | +| |*`CU_JIT_INFO_LOG_BUFFER`* | | Pointer to a buffer in which to print any log messages that are informational in nature (the buffer size is specified via option CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES) Option type: char * Applies to: compiler and linker. | +| |*`CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES`* | | IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator) OUT: Amount of log buffer filled with messages Option type: unsigned int Applies to: compiler and linker. | +| |*`CU_JIT_OPTIMIZATION_LEVEL`* | | Level of optimizations to apply to generated code (0 - 4), with 4 being the default and highest level of optimizations. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_TARGET_FROM_CUCONTEXT`* | | No option value required. Determines the target based on the current attached context (default) Option type: No option value needed Applies to: compiler and linker. | +| |*`CU_JIT_TARGET`* | | Target is chosen based on supplied CUjit_target. Cannot be combined with CU_JIT_THREADS_PER_BLOCK. Option type: unsigned int for enumerated type CUjit_target Applies to: compiler and linker. | +| |*`CU_JIT_FALLBACK_STRATEGY`* | | Specifies choice of fallback strategy if matching cubin is not found. Choice is based on supplied CUjit_fallback. This option cannot be used with cuLink* APIs as the linker requires exact matches. Option type: unsigned int for enumerated type CUjit_fallback Applies to: compiler only. | +| |*`CU_JIT_GENERATE_DEBUG_INFO`* | | Specifies whether to create debug information in output (-g) (0: false, default) Option type: int Applies to: compiler and linker. | +| |*`CU_JIT_LOG_VERBOSE`* | | Generate verbose log messages (0: false, default) Option type: int Applies to: compiler and linker. | +| |*`CU_JIT_GENERATE_LINE_INFO`* | | Generate line number information (-lineinfo) (0: false, default) Option type: int Applies to: compiler only. | +| |*`CU_JIT_CACHE_MODE`* | | Specifies whether to enable caching explicitly (-dlcm) Choice is based on supplied CUjit_cacheMode_enum. Option type: unsigned int for enumerated type CUjit_cacheMode_enum Applies to: compiler only. | +| |*`CU_JIT_NUM_OPTIONS`* | | | +| enum |***`CUjit_target`*** | | Online compilation targets | +| 10 |*`CU_TARGET_COMPUTE_10`* | | Compute device class 1.0. | +| 11 |*`CU_TARGET_COMPUTE_11`* | | Compute device class 1.1. | +| 12 |*`CU_TARGET_COMPUTE_12`* | | Compute device class 1.2. | +| 13 |*`CU_TARGET_COMPUTE_13`* | | Compute device class 1.3. | +| 20 |*`CU_TARGET_COMPUTE_20`* | | Compute device class 2.0. | +| 21 |*`CU_TARGET_COMPUTE_21`* | | Compute device class 2.1. | +| 30 |*`CU_TARGET_COMPUTE_30`* | | Compute device class 3.0. | +| 32 |*`CU_TARGET_COMPUTE_32`* | | Compute device class 3.2. | +| 35 |*`CU_TARGET_COMPUTE_35`* | | Compute device class 3.5. | +| 37 |*`CU_TARGET_COMPUTE_37`* | | Compute device class 3.7. | +| 50 |*`CU_TARGET_COMPUTE_50`* | | Compute device class 5.0. | +| 52 |*`CU_TARGET_COMPUTE_52`* | | Compute device class 5.2. | +| enum |***`CUjitInputType`*** | | Device code formats | +| 0 |*`CU_JIT_INPUT_CUBIN`* | | Compiled device-class-specific device code Applicable options: none. | +| |*`CU_JIT_INPUT_PTX`* | | PTX source code Applicable options: PTX compiler options. | +| |*`CU_JIT_INPUT_FATBINARY`* | | Bundle of multiple cubins and/or PTX of some device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_INPUT_OBJECT`* | | Host object with embedded device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_INPUT_LIBRARY`* | | Archive of host objects with embedded device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_NUM_INPUT_TYPES`* | | | +| enum |***`CUlimit`*** |***`hipLimit_t`*** | Limits | +| 0x00 |*`CU_LIMIT_STACK_SIZE`* | | GPU thread stack size. | +| 0x01 |*`CU_LIMIT_PRINTF_FIFO_SIZE`* | | GPU printf FIFO size. | +| 0x02 |*`CU_LIMIT_MALLOC_HEAP_SIZE`* |*`hipLimitMallocHeapSize`* | GPU malloc heap size. | +| 0x03 |*`CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH`* | | GPU device runtime launch synchronize depth. | +| 0x04 |*`CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT`* | | GPU device runtime pending launch count. | +| |*`CU_LIMIT_MAX`* | | | +| enum |***`CUmemAttach_flags`*** | | CUDA Mem Attach Flags | +| 0x1 |*`CU_MEM_ATTACH_GLOBAL`* | | Memory can be accessed by any stream on any device. | +| 0x2 |*`CU_MEM_ATTACH_HOST`* | | Memory cannot be accessed by any stream on any device. | +| 0x4 |*`CU_MEM_ATTACH_SINGLE`* | | Memory can only be accessed by a single stream on the associated device. | +| enum |***`CUmemorytype`*** | | Memory types | +| 0x01 |*`CU_MEMORYTYPE_HOST`* | | Host memory | +| 0x02 |*`CU_MEMORYTYPE_DEVICE`* | | Device memory | +| 0x03 |*`CU_MEMORYTYPE_ARRAY`* | | Array memory | +| 0x04 |*`CU_MEMORYTYPE_UNIFIED`* | | Unified device or host memory | +| enum |***`CUoccupancy_flags`*** | | Occupancy calculator flag | +| 0x00 |*`CU_OCCUPANCY_DEFAULT`* | | Default behavior | +| 0x01 |*`CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`* | | Assume global caching is enabled and cannot be automatically turned off | +| enum |***`CUpointer_attribute`*** | | Pointer information | +| 1 |*`CU_POINTER_ATTRIBUTE_CONTEXT`* | | The CUcontext on which a pointer was allocated or registered | +| 2 |*`CU_POINTER_ATTRIBUTE_MEMORY_TYPE`* | | The CUmemorytype describing the physical location of a pointer | +| 3 |*`CU_POINTER_ATTRIBUTE_DEVICE_POINTER`* | | The address at which a pointer's memory may be accessed on the device | +| 4 |*`CU_POINTER_ATTRIBUTE_HOST_POINTER`* | | The address at which a pointer's memory may be accessed on the host | +| 5 |*`CU_POINTER_ATTRIBUTE_P2P_TOKENS`* | | A pair of tokens for use with the nv-p2p.h Linux kernel interface | +| 6 |*`CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`* | | Synchronize every synchronous memory operation initiated on this region | +| 7 |*`CU_POINTER_ATTRIBUTE_BUFFER_ID`* | | A process-wide unique ID for an allocated memory region | +| 8 |*`CU_POINTER_ATTRIBUTE_IS_MANAGED`* | | Indicates if the pointer points to managed memory | +| enum |***`CUmemorytype`*** | | Resource types | +| 0x00 |*`CU_RESOURCE_TYPE_ARRAY`* | | Array resoure | +| 0x01 |*`CU_RESOURCE_TYPE_MIPMAPPED_ARRAY`* | | Mipmapped array resource | +| 0x02 |*`CU_RESOURCE_TYPE_LINEAR`* | | Linear resource | +| 0x03 |*`CU_RESOURCE_TYPE_PITCH2D`* | | Pitch 2D resource | +| enum |***`CUresourceViewFormat`*** | | Resource view format | +| 0x00 |*`CU_RES_VIEW_FORMAT_NONE`* | | No resource view format (use underlying resource format) | +| 0x01 |*`CU_RES_VIEW_FORMAT_UINT_1X8`* | | 1 channel unsigned 8-bit integers | +| 0x02 |*`CU_RES_VIEW_FORMAT_UINT_2X8`* | | 2 channel unsigned 8-bit integers | +| 0x03 |*`CU_RES_VIEW_FORMAT_UINT_4X8`* | | 4 channel unsigned 8-bit integers | +| 0x04 |*`CU_RES_VIEW_FORMAT_SINT_1X8`* | | 1 channel signed 8-bit integers | +| 0x05 |*`CU_RES_VIEW_FORMAT_SINT_2X8`* | | 2 channel signed 8-bit integers | +| 0x06 |*`CU_RES_VIEW_FORMAT_SINT_4X8`* | | 4 channel signed 8-bit integers | +| 0x07 |*`CU_RES_VIEW_FORMAT_UINT_1X16`* | | 1 channel unsigned 16-bit integers | +| 0x08 |*`CU_RES_VIEW_FORMAT_UINT_2X16`* | | 2 channel unsigned 16-bit integers | +| 0x09 |*`CU_RES_VIEW_FORMAT_UINT_4X16`* | | 4 channel unsigned 16-bit integers | +| 0x0a |*`CU_RES_VIEW_FORMAT_SINT_1X16`* | | 1 channel signed 16-bit integers | +| 0x0b |*`CU_RES_VIEW_FORMAT_SINT_2X16`* | | 2 channel signed 16-bit integers | +| 0x0c |*`CU_RES_VIEW_FORMAT_SINT_4X16`* | | 4 channel signed 16-bit integers | +| 0x0d |*`CU_RES_VIEW_FORMAT_UINT_1X32`* | | 1 channel unsigned 32-bit integers | +| 0x0e |*`CU_RES_VIEW_FORMAT_UINT_2X32`* | | 2 channel unsigned 32-bit integers | +| 0x0f |*`CU_RES_VIEW_FORMAT_UINT_4X32`* | | 4 channel unsigned 32-bit integers | +| 0x10 |*`CU_RES_VIEW_FORMAT_SINT_1X32`* | | 1 channel signed 32-bit integers | +| 0x11 |*`CU_RES_VIEW_FORMAT_SINT_2X32`* | | 2 channel signed 32-bit integers | +| 0x12 |*`CU_RES_VIEW_FORMAT_SINT_4X32`* | | 4 channel signed 32-bit integers | +| 0x13 |*`CU_RES_VIEW_FORMAT_FLOAT_1X16`* | | 1 channel 16-bit floating point | +| 0x14 |*`CU_RES_VIEW_FORMAT_FLOAT_2X16`* | | 2 channel 16-bit floating point | +| 0x15 |*`CU_RES_VIEW_FORMAT_FLOAT_4X16`* | | 4 channel 16-bit floating point | +| 0x16 |*`CU_RES_VIEW_FORMAT_FLOAT_1X32`* | | 1 channel 32-bit floating point | +| 0x17 |*`CU_RES_VIEW_FORMAT_FLOAT_2X32`* | | 2 channel 32-bit floating point | +| 0x18 |*`CU_RES_VIEW_FORMAT_FLOAT_4X32`* | | 4 channel 32-bit floating point | +| 0x19 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC1`* | | Block compressed 1 | +| 0x1a |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC3`* | | Block compressed 2 | +| 0x1b |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC3`* | | Block compressed 3 | +| 0x1c |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC4`* | | Block compressed 4 unsigned | +| 0x1d |*`CU_RES_VIEW_FORMAT_SIGNED_BC4`* | | Block compressed 4 signed | +| 0x1e |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC5`* | | Block compressed 5 unsigned | +| 0x1f |*`CU_RES_VIEW_FORMAT_SIGNED_BC5`* | | Block compressed 5 signed | +| 0x20 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC6H`* | | Block compressed 6 unsigned half-float | +| 0x21 |*`CU_RES_VIEW_FORMAT_SIGNED_BC6H`* | | Block compressed 6 signed half-float | +| 0x22 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC7`* | | Block compressed 7 | +| enum |***`CUresult`*** |***`hipError_t`*** | Error codes | +| 0 |*`CUDA_SUCCESS`* |*`hipSuccess`* | The API call returned with no errors. In the case of query calls, this can also mean that the operation being queried is complete (see cuEventQuery() and cuStreamQuery()). | +| 1 |*`CUDA_ERROR_INVALID_VALUE`* |*`hipErrorInvalidValue`* | This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. | +| 2 |*`CUDA_ERROR_OUT_OF_MEMORY`* |*`hipErrorMemoryAllocation`* | The API call failed because it was unable to allocate enough memory to perform the requested operation. | +| 3 |*`CUDA_ERROR_NOT_INITIALIZED`* |*`hipErrorNotInitialized`* | This indicates that the CUDA driver has not been initialized with cuInit() or that initialization has failed. | +| 4 |*`CUDA_ERROR_DEINITIALIZED`* |*`hipErrorDeinitialized`* | This indicates that the CUDA driver is in the process of shutting down. | +| 5 |*`CUDA_ERROR_PROFILER_DISABLED`* |*`hipErrorProfilerDisabled`* | This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling tools like visual profiler. | +| 6 |*`CUDA_ERROR_PROFILER_NOT_INITIALIZED`* |*`hipErrorProfilerNotInitialized`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to attempt to enable/disable the profiling via cuProfilerStart or cuProfilerStop without initialization. | +| 7 |*`CUDA_ERROR_PROFILER_ALREADY_STARTED`* |*`hipErrorProfilerAlreadyStarted`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cuProfilerStart() when profiling is already enabled. | +| 8 |*`CUDA_ERROR_PROFILER_ALREADY_STOPPED`* |*`hipErrorProfilerAlreadyStopped`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cuProfilerStop() when profiling is already disabled. | +| 100 |*`CUDA_ERROR_NO_DEVICE`* |*`hipErrorNoDevice`* | This indicates that no CUDA-capable devices were detected by the installed CUDA driver. | +| 101 |*`CUDA_ERROR_INVALID_DEVICE`* |*`hipErrorInvalidDevice`* | This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device. | +| 200 |*`CUDA_ERROR_INVALID_IMAGE`* |*`hipErrorInvalidImage`* | This indicates that the device kernel image is invalid. This can also indicate an invalid CUDA module. | +| 201 |*`CUDA_ERROR_INVALID_CONTEXT`* |*`hipErrorInvalidContext`* | This most frequently indicates that there is no context bound to the current thread. This can also be returned if the context passed to an API call is not a valid handle (such as a context that has had cuCtxDestroy() invoked on it). This can also be returned if a user mixes different API versions (i.e. 3010 context with 3020 API calls). See cuCtxGetApiVersion() for more details. | +| 202 |*`CUDA_ERROR_CONTEXT_ALREADY_CURRENT`* |*`hipErrorContextAlreadyCurrent`* | This indicated that the context being supplied as a parameter to the API call was already the active context. Deprecated This error return is deprecated as of CUDA 3.2. It is no longer an error to attempt to push the active context via cuCtxPushCurrent(). | +| 205 |*`CUDA_ERROR_MAP_FAILED`* |*`hipErrorMapFailed`* | This indicates that a map or register operation has failed. | +| 206 |*`CUDA_ERROR_UNMAP_FAILED`* |*`hipErrorUnmapFailed`* | This indicates that an unmap or unregister operation has failed. | +| 207 |*`CUDA_ERROR_ARRAY_IS_MAPPED`* |*`hipErrorArrayIsMapped`* | This indicates that the specified array is currently mapped and thus cannot be destroyed. | +| 208 |*`CUDA_ERROR_ALREADY_MAPPED`* |*`hipErrorAlreadyMapped`* | This indicates that the resource is already mapped. | +| 209 |*`CUDA_ERROR_NO_BINARY_FOR_GPU`* |*`hipErrorNoBinaryForGpu* | This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies code generation options for a particular CUDA source file that do not include the corresponding device configuration. | +| 210 |*`CUDA_ERROR_ALREADY_ACQUIRED`* |*`hipErrorAlreadyAcquired* | This indicates that a resource has already been acquired. | +| 211 |*`CUDA_ERROR_NOT_MAPPED`* |*`hipErrorNotMapped`* | This indicates that a resource is not mapped. | +| 212 |*`CUDA_ERROR_NOT_MAPPED_AS_ARRAY`* |*`hipErrorNotMappedAsArray`* | This indicates that a mapped resource is not available for access as an array. | +| 213 |*`CUDA_ERROR_NOT_MAPPED_AS_POINTER`* |*`hipErrorNotMappedAsPointer`* | This indicates that a mapped resource is not available for access as a pointer. | +| 214 |*`CUDA_ERROR_ECC_UNCORRECTABLE`* |*`hipErrorECCNotCorrectable`* | This indicates that an uncorrectable ECC error was detected during execution. | +| 215 |*`CUDA_ERROR_UNSUPPORTED_LIMIT`* |*`hipErrorUnsupportedLimit`* | This indicates that the CUlimit passed to the API call is not supported by the active device. | +| 216 |*`CUDA_ERROR_CONTEXT_ALREADY_IN_USE`* |*`hipErrorContextAlreadyInUse`* | This indicates that the CUcontext passed to the API call can only be bound to a single CPU thread at a time but is already bound to a CPU thread. | +| 217 |*`CUDA_ERROR_PEER_ACCESS_UNSUPPORTED`* |*`hipErrorPeerAccessUnsupported`* | This indicates that peer access is not supported across the given devices. | +| 218 |*`CUDA_ERROR_INVALID_PTX`* |*`hipErrorInvalidKernelFile`* | This indicates that a PTX JIT compilation failed. | +| 219 |*`CUDA_ERROR_INVALID_GRAPHICS_CONTEXT`* |*`hipErrorInvalidGraphicsContext`* | This indicates an error with OpenGL or DirectX context. | +| 300 |*`CUDA_ERROR_INVALID_SOURCE`* |*`hipErrorInvalidSource`* | This indicates that the device kernel source is invalid. | +| 301 |*`CUDA_ERROR_FILE_NOT_FOUND`* |*`hipErrorFileNotFound`* | This indicates that the file specified was not found. | +| 302 |*`CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND`* |*`hipErrorSharedObjectSymbolNotFound`* | This indicates that a link to a shared object failed to resolve. | +| 303 |*`CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`* |*`hipErrorSharedObjectInitFailed`* | This indicates that initialization of a shared object failed. | +| 304 |*`CUDA_ERROR_OPERATING_SYSTEM`* |*`hipErrorOperatingSystem`* | This indicates that an OS call failed. | +| 400 |*`CUDA_ERROR_INVALID_HANDLE`* |*`hipErrorInvalidResourceHandle`* | This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like CUstream and CUevent. | +| 500 |*`CUDA_ERROR_NOT_FOUND`* |*`hipErrorNotFound`* | This indicates that a named symbol was not found. Examples of symbols are global/constant variable names, texture names, and surface names. | +| 600 |*`CUDA_ERROR_NOT_READY`* |*`hipErrorNotReady`* | This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error, but must be indicated differently than CUDA_SUCCESS (which indicates completion). Calls that may return this value include cuEventQuery() and cuStreamQuery(). | +| 700 |*`CUDA_ERROR_ILLEGAL_ADDRESS`* |*`hipErrorIllegalAddress`* | While executing a kernel, the device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA. | + + +## **2. Error Handling** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **3. Initialization** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **4. Version Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **5. Device Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + +## **6. Device Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **7. Primary Context Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **8. Context Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **9. Context Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **10. Module Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **11. Memory Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **12. Unified Addressing** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **13. Stream Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **14. Event Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **15. Execution Control** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **16. Execution Control [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **17. Occupancy** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **18. Texture Reference Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **19. Texture Reference Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **20. Surface Reference Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **21. Texture Object Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **22. Surface Object Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **23. Peer Context Memory Access** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **24. Graphics Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **25. Profiler Control** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **26. OpenGL Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **27. Direct3D 9 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **28. Direct3D 10 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **29. Direct3D 11 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **30. VDPAU Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 350ddd4e32..c5df7f6bcd 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -1,34 +1,36 @@ -**1. Device Management** +# CUDA Runtime API functions supported by HIP + +## **1. Device Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaChooseDevice` | `hipChooseDevice` | Select compute-device which best matches criteria. | +| `cudaChooseDevice` | `hipChooseDevice` | Select compute-device which best matches criteria. | | `cudaDeviceGetAttribute` | `hipDeviceGetAttribute` | Returns information about the device. | -| `cudaDeviceGetByPCIBusId` | | Returns a handle to a compute device. | +| `cudaDeviceGetByPCIBusId` | `hipDeviceGetByPCIBusId` | Returns a handle to a compute device. | | `cudaDeviceGetCacheConfig` | `hipDeviceGetCacheConfig` | Returns the preferred cache configuration for the current device. | -| `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | -| `cudaDeviceGetPCIBusId` | | Returns a PCI Bus Id string for the device. | +| `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | +| `cudaDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` | Returns a PCI Bus Id string for the device. | | `cudaDeviceGetSharedMemConfig` | `hipDeviceGetSharedMemConfig` | Returns the shared memory configuration for the current device. | | `cudaDeviceGetStreamPriorityRange` | | Returns numerical values that correspond to the least and greatest stream priorities. | | `cudaDeviceReset` | `hipDeviceReset` | Destroy all allocations and reset all state on the current device in the current process. | | `cudaDeviceSetCacheConfig` | `hipDeviceSetCacheConfig` | Sets the preferred cache configuration for the current device. | -| `cudaDeviceSetLimit` | `hipDeviceSetLimit` | Set resource limits. | +| `cudaDeviceSetLimit` | `hipDeviceSetLimit` | Set resource limits. | | `cudaDeviceSetSharedMemConfig` | `hipDeviceSetSharedMemConfig` | Sets the shared memory configuration for the current device. | | `cudaDeviceSynchronize` | `hipDeviceSynchronize` | Wait for compute device to finish. | | `cudaGetDevice` | `hipGetDevice` | Returns which device is currently being used. | | `cudaGetDeviceCount` | `hipGetDeviceCount` | Returns the number of compute-capable devices. | | `cudaGetDeviceFlags` | | Gets the flags for the current device. | | `cudaGetDeviceProperties` | `hipGetDeviceProperties` | Returns information about the compute-device. | -| `cudaIpcCloseMemHandle` | | Close memory mapped with cudaIpcOpenMemHandle. | -| `cudaIpcGetEventHandle` | | Gets an interprocess handle for a previously allocated event. | -| `cudaIpcGetMemHandle` | | Gets an interprocess memory handle for an existing device memory allocation. | -| `cudaIpcOpenEventHandle` | | Opens an interprocess event handle for use in the current process. | -| `cudaIpcOpenMemHandle` | | Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process. | +| `cudaIpcCloseMemHandle` | `hipIpcCloseMemHandle` | Close memory mapped with cudaIpcOpenMemHandle. | +| `cudaIpcGetEventHandle` | `hipIpcGetEventHandle` | Gets an interprocess handle for a previously allocated event. | +| `cudaIpcGetMemHandle` | `hipIpcGetMemHandle` | Gets an interprocess memory handle for an existing device memory allocation. | +| `cudaIpcOpenEventHandle` | `hipIpcOpenEventHandle` | Opens an interprocess event handle for use in the current process. | +| `cudaIpcOpenMemHandle` | `hipIpcOpenMemHandle` | Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process. | | `cudaSetDevice` | `hipSetDevice` | Set device to be used for GPU executions. | | `cudaSetDeviceFlags` | `hipSetDeviceFlags` | Sets flags to be used for device executions. | -| `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. |` +| `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. | -**2. Error Handling** +## **2. Error Handling** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -37,12 +39,12 @@ | `cudaGetLastError` | `hipGetLastError` | Returns the last error from a runtime call. | | `cudaPeekAtLastError` | `hipPeekAtLastError` | Returns the last error from a runtime call. | -**3. Stream Management** +## **3. Stream Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaStreamAddCallback` | | Add a callback to a compute stream. | -| `cudaStreamAttachMemAsync` | | Attach managed memory to a stream asynchronously. | +| `cudaStreamAddCallback` | `hipStreamAddCallback` | Add a callback to a compute stream. | +| `cudaStreamAttachMemAsync` | | Attach managed memory to a stream asynchronously. | | `cudaStreamCreate` | `hipStreamCreate` | Create an asynchronous stream. | | `cudaStreamCreateWithFlags` | `hipStreamCreateWithFlags` | Create an asynchronous stream. | | `cudaStreamCreateWithPriority` | | Create an asynchronous stream with the specified priority. | @@ -53,7 +55,7 @@ | `cudaStreamSynchronize` | `hipStreamSynchronize` | Waits for stream tasks to complete. | | `cudaStreamWaitEvent` | `hipStreamWaitEvent` | Make a compute stream wait on an event. | -**4. Event Management** +## **4. Event Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -65,7 +67,7 @@ | `cudaEventRecord` | `hipEventRecord` | Records an event. | | `cudaEventSynchronize` | `hipEventSynchronize` | Waits for an event to complete. | -**5. Execution Control** +## **5. Execution Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -78,46 +80,54 @@ | `cudaSetDoubleForDevice` | | Converts a double argument to be executed on a device. | | `cudaSetDoubleForHost` | | Converts a double argument after execution on a device. | -**6. Occupancy** +## **6. Occupancy** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | | Returns occupancy for a device function. | +| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | `hipOccupancyMaxActiveBlocksPerMultiprocessor`| Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -**7. Memory Management** +## **7. Execution Control [deprecated since 7.0]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| `cudaConfigureCall` | | Configure a device-launch. | +| `cudaLaunch` | | Launches a device function. | +| `cudaSetupArgument` | | Configure a device launch. | + +## **8. Memory Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaArrayGetInfo` | | Gets info about the specified cudaArray. | | `cudaFree` | `hipFree` | Frees memory on the device. | -| `cudaFreeArray` | | Frees an array on the device. | +| `cudaFreeArray` | `hipFreeArray` | Frees an array on the device. | | `cudaFreeHost` | `hipHostFree` | Frees page-locked memory. | | `cudaFreeMipmappedArray` | | Frees a mipmapped array on the device. | | `cudaGetMipmappedArrayLevel` | | Gets a mipmap level of a CUDA mipmapped array. | | `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol. | | `cudaGetSymbolSize` | | Finds the size of the object associated with a CUDA symbol. | -| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. | -| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. | -| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. | +| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. | +| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. | +| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. | | `cudaHostRegister` | `hipHostRegister` | Registers an existing host memory range for use by CUDA. | | `cudaHostUnregister` | `hipHostUnregister` | Unregisters a memory range that was registered with cudaHostRegister. | | `cudaMalloc` | `hipMalloc` | Allocate memory on the device. | | `cudaMalloc3D` | | Allocates logical 1D, 2D, or 3D memory objects on the device. | | `cudaMalloc3DArray` | | Allocate an array on the device. | -| `cudaMallocArray` | | Allocate an array on the device. | -| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. | +| `cudaMallocArray` | `hipMallocArray` | Allocate an array on the device. | +| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. | | `cudaMallocManaged` | | Allocates memory that will be automatically managed by the Unified Memory system. | | `cudaMallocMipmappedArray` | | Allocate a mipmapped array on the device. | | `cudaMallocPitch` | | Allocates pitched memory on the device. | -| `cudaMemGetInfo` | | Gets free and total device memory. | +| `cudaMemGetInfo` | `hipMemGetInfo` | Gets free and total device memory. | | `cudaMemcpy` | `hipMemcpy` | Copies data between host and device. | -| `cudaMemcpy2D` | | Copies data between host and device. | +| `cudaMemcpy2D` | `hipMemcpy2D` | Copies data between host and device. | | `cudaMemcpy2DArrayToArray` | | Copies data between host and device. | | `cudaMemcpy2DAsync` | | Copies data between host and device. | | `cudaMemcpy2DFromArray` | | Copies data between host and device. | | `cudaMemcpy2DFromArrayAsync` | | Copies data between host and device. | -| `cudaMemcpy2DToArray` | | Copies data between host and device. | +| `cudaMemcpy2DToArray` | `hipMemcpy2DToArray` | Copies data between host and device. | | `cudaMemcpy2DToArrayAsync` | | Copies data between host and device. | | `cudaMemcpy3D` | | Copies data between 3D objects. | | `cudaMemcpy3DAsync` | | Copies data between 3D objects. | @@ -131,27 +141,27 @@ | `cudaMemcpyFromSymbolAsync` | | Copies data from the given symbol on the device. | | `cudaMemcpyPeer` | `hipMemcpyPeer` | Copies memory between two devices. | | `cudaMemcpyPeerAsync` | `hipMemcpyPeerAsync` | Copies memory between two devices asynchronously. | -| `cudaMemcpyToArray` | | Copies data between host and device. | +| `cudaMemcpyToArray` | `hipMemcpyToArray` | Copies data between host and device. | | `cudaMemcpyToArrayAsync` | | Copies data between host and device. | | `cudaMemcpyToSymbol` | `hipMemcpyToSymbol` | Copies data to the given symbol on the device. | -| `cudaMemcpyToSymbolAsync` | | Copies data to the given symbol on the device. | +| `cudaMemcpyToSymbolAsync` | `hipMemcpyToSymbolAsync` | Copies data to the given symbol on the device. | | `cudaMemset` | `hipMemset` | Initializes or sets device memory to a value. | | `cudaMemset2D` | | Initializes or sets device memory to a value. | | `cudaMemset2DAsync` | | Initializes or sets device memory to a value. | | `cudaMemset3D` | | Initializes or sets device memory to a value. | | `cudaMemset3DAsync` | | Initializes or sets device memory to a value. | | `cudaMemsetAsync` | `hipMemsetAsync` | Initializes or sets device memory to a value. | -| `make\_cudaExtent` | | Returns a cudaExtent based on input parameters. | -| `make\_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | -| `make\_cudaPos` | | Returns a cudaPos based on input parameters. | +| `make_cudaExtent` | | Returns a cudaExtent based on input parameters. | +| `make_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | +| `make_cudaPos` | | Returns a cudaPos based on input parameters. | -**8. Unified Addressing** +## **9. Unified Addressing** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaPointerGetAttributes` | `hipPointerGetAttributes` | Returns attributes about a specified pointer. | -**9. Peer Device Memory Access** +## **10. Peer Device Memory Access** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -159,7 +169,7 @@ | `cudaDeviceDisablePeerAccess` | `hipDeviceDisablePeerAccess` | Disables direct access to memory allocations on a peer device. | | `cudaDeviceEnablePeerAccess` | `hipDeviceEnablePeerAccess` | Enables direct access to memory allocations on a peer device. | -**10. OpenGL Interoperability** +## **11. OpenGL Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -168,7 +178,7 @@ | `cudaGraphicsGLRegisterImage` | | Register an OpenGL texture or renderbuffer object. | | `cudaWGLGetDevice` | | Gets the CUDA device associated with hGpu. | -**11. Graphics Interoperability** +## **12. Graphics Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -180,7 +190,7 @@ | `cudaGraphicsUnmapResources` | | Unmap graphics resources. | | `cudaGraphicsUnregisterResource` | | Unregisters a graphics resource for access by CUDA. | -**12. Texture Reference Management** +## **13. Texture Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -194,14 +204,14 @@ | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | | `cudaUnbindTexture` | | Unbinds a texture. | -**13. Surface Reference Management** +## **14. Surface Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaBindSurfaceToArray` | | Binds an array to a surface. | | `cudaGetSurfaceReference` | | Get the surface reference associated with a symbol. | -**14. Texture Object Management** +## **15. Texture Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -211,7 +221,7 @@ | `cudaGetTextureObjectResourceViewDesc` | | Returns a texture object's resource view descriptor. | | `cudaGetTextureObjectTextureDesc` | | Returns a texture object's texture descriptor. | -**15. Surface Object Management** +## **16. Surface Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -219,25 +229,24 @@ | `cudaDestroySurfaceObject` | | Destroys a surface object. | | `cudaGetSurfaceObjectResourceDesc` | | Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject. | -**16. Version Management** +## **17. Version Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaDriverGetVersion` | `hipDriverGetVersion` | Returns the CUDA driver version. | -| `cudaRuntimeGetVersion` | | Returns the CUDA Runtime version. | +| `cudaRuntimeGetVersion` | `hipRuntimeGetVersion` | Returns the CUDA Runtime version. | -**17. C++ API Routines (7.0 contains, 7.5 doesn’t)** -> Will not support for HIP (probably) +## **18. C++ API Routines** +*(7.0 contains, 7.5 doesn’t)* | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaBindSurfaceToArray` | | Binds an array to a surface. | -| `cudaBindTexture` | | Binds a memory area to a texture. | +| `cudaBindTexture` | `hipBindTexture` | Binds a memory area to a texture. | | `cudaBindTexture2D` | | Binds a 2D memory area to a texture. | | `cudaBindTextureToArray` | | Binds an array to a texture. | | `cudaBindTextureToMipmappedArray` | | Binds a mipmapped array to a texture. | -| `cudaCreateChannelDesc` | | Returns a channel descriptor using the specified format. | -| `cudaEventCreate` | | Creates an event object with the specified flags. | +| `cudaCreateChannelDesc` | `hipCreateChannelDesc` | Returns a channel descriptor using the specified format. | | `cudaFuncGetAttributes` | | Find out attributes for a given function. | | `cudaFuncSetCacheConfig` | | Sets the preferred cache configuration for a device function. | | `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol | @@ -251,20 +260,378 @@ | `cudaMemcpyFromSymbolAsync` | | Copies data from the given symbol on the device. | | `cudaMemcpyToSymbol` | | Copies data to the given symbol on the device. | | `cudaMemcpyToSymbolAsync` | | Async copies data to the given symbol on the device. | -| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | | Returns occupancy for a device function. | +| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | `hipOccupancyMaxActiveBlocksPerMultiprocessor` | Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -| `cudaOccupancyMaxPotentialBlockSize` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | +| `cudaOccupancyMaxPotentialBlockSize` | `hipOccupancyMaxPotentialBlockSize` | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeVariableSMem` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeWithFlags` | | Returns grid and block size that achived maximum potential occupancy for a device function with the specified flags. | | `cudaSetupArgument` | | Configure a device launch. | | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | -| `cudaUnbindTexture` | | Unbinds a texture. | +| `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | -**18. Profiler Control** +## **19. Profiler Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaProfilerInitialize` | | Initialize the CUDA profiler. | | `cudaProfilerStart` | `hipProfilerStart` | Enable profiling. | | `cudaProfilerStop` | `hipProfilerStop` | Disable profiling. | + +# Data types used by CUDA Runtime API and supported by HIP + +## **20. Data types** + +| **type** | **CUDA** | **HIP** | **CUDA description** | +|-------------:|-----------------------------------------------|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| struct | `cudaChannelFormatDesc` | `hipChannelFormatDesc` | CUDA Channel format descriptor. | +| struct | `cudaDeviceProp` | `hipDeviceProp_t` | CUDA device properties. | +| struct | `cudaExtent` | | CUDA extent (width, height, depth). | +| struct | `cudaFuncAttributes` | | CUDA function attributes. | +| struct | `cudaIpcEventHandle_t` | `hipIpcEventHandle_t` | CUDA IPC event handle. | +| struct | `cudaIpcMemHandle_t` | `hipIpcMemHandle_t` | CUDA IPC memory handle. | +| struct | `cudaMemcpy3DParms` | | CUDA 3D memory copying parameters. | +| struct | `cudaMemcpy3DPeerParms` | | CUDA 3D cross-device memory copying parameters. | +| struct | `cudaPitchedPtr` | | CUDA Pitched memory pointer. | +| struct | `cudaPointerAttributes` | `hipPointerAttribute_t` | CUDA pointer attributes. | +| struct | `cudaPos` | | CUDA 3D position. | +| struct | `cudaResourceDesc` | | CUDA resource descriptor. | +| struct | `cudaResourceViewDesc` | | CUDA resource view descriptor. | +| struct | `cudaTextureDesc` | | CUDA texture descriptor. | +| struct | `surfaceReference` | | CUDA Surface reference. | +| struct | `textureReference` | `textureReference` | CUDA texture reference. | +| enum |***`cudaChannelFormatKind`*** |***`hipChannelFormatKind`*** | Channel format kind. | +| 0 |*`cudaChannelFormatKindSigned`* |*`hipChannelFormatKindSigned`* | Signed channel format. | +| 1 |*`cudaChannelFormatKindUnsigned`* |*`hipChannelFormatKindUnsigned`* | Unsigned channel format. | +| 2 |*`cudaChannelFormatKindFloat`* |*`hipChannelFormatKindFloat`* | Float channel format. | +| 3 |*`cudaChannelFormatKindNone`* |*`hipChannelFormatKindNone`* | No channel format. | +| enum |***`cudaComputeMode`*** | | CUDA device compute modes. | +| 0 |*`cudaComputeModeDefault`* | | Default compute mode (Multiple threads can use ::cudaSetDevice() with this device). | +| 1 |*`cudaComputeModeExclusive`* | | Compute-exclusive-thread mode (Only one thread in one process will be able to use ::cudaSetDevice() with this device). | +| 2 |*`cudaComputeModeProhibited`* | | Compute-prohibited mode (No threads can use ::cudaSetDevice() with this device). | +| 3 |*`cudaComputeModeExclusiveProcess`* | | Compute-exclusive-process mode (Many threads in one process will be able to use ::cudaSetDevice() with this device). | +| enum |***`cudaDeviceAttr`*** |***`hipDeviceAttribute_t`*** | CUDA device attributes. | +| 1 |*`cudaDevAttrMaxThreadsPerBlock`* |*`hipDeviceAttributeMaxThreadsPerBlock`* | Maximum number of threads per block. | +| 2 |*`cudaDevAttrMaxBlockDimX`* |*`hipDeviceAttributeMaxBlockDimX`* | Maximum block dimension X. | +| 3 |*`cudaDevAttrMaxBlockDimY`* |*`hipDeviceAttributeMaxBlockDimY`* | Maximum block dimension Y. | +| 4 |*`cudaDevAttrMaxBlockDimZ`* |*`hipDeviceAttributeMaxBlockDimZ`* | Maximum block dimension Y. | +| 5 |*`cudaDevAttrMaxGridDimX`* |*`hipDeviceAttributeMaxGridDimX`* | Maximum grid dimension X. | +| 6 |*`cudaDevAttrMaxGridDimY`* |*`hipDeviceAttributeMaxGridDimY`* | Maximum grid dimension Y. | +| 7 |*`cudaDevAttrMaxGridDimZ`* |*`hipDeviceAttributeMaxGridDimZ`* | Maximum grid dimension Y. | +| 8 |*`cudaDevAttrMaxSharedMemoryPerBlock`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Maximum shared memory available per block in bytes. | +| 9 |*`cudaDevAttrTotalConstantMemory`* |*`hipDeviceAttributeTotalConstantMemory`* | Memory available on device for \__constant__ variables in a CUDA C kernel in bytes. | +| 10 |*`cudaDevAttrWarpSize`* |*`hipDeviceAttributeWarpSize`* | Warp size in threads. | +| 11 |*`cudaDevAttrMaxPitch`* | | Maximum pitch in bytes allowed by memory copies. | +| 12 |*`cudaDevAttrMaxRegistersPerBlock`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Maximum number of 32-bit registers available per block. | +| 13 |*`cudaDevAttrClockRate`* |*`hipDeviceAttributeClockRate`* | Peak clock frequency in kilohertz. | +| 14 |*`cudaDevAttrTextureAlignment`* | | Alignment requirement for textures. | +| 15 |*`cudaDevAttrGpuOverlap`* | | Device can possibly copy memory and execute a kernel concurrently. | +| 16 |*`cudaDevAttrMultiProcessorCount`* |*`hipDeviceAttributeMultiprocessorCount`* | Number of multiprocessors on device. | +| 17 |*`cudaDevAttrKernelExecTimeout`* | | Specifies whether there is a run time limit on kernels. | +| 18 |*`cudaDevAttrIntegrated`* | | Device is integrated with host memory. | +| 19 |*`cudaDevAttrCanMapHostMemory`* | | Device can map host memory into CUDA address space. | +| 20 |*`cudaDevAttrComputeMode`* |*`hipDeviceAttributeComputeMode`* | Compute mode (See cudaComputeMode for details). | +| 21 |*`cudaDevAttrMaxTexture1DWidth`* | | Maximum 1D texture width. | +| 22 |*`cudaDevAttrMaxTexture2DWidth`* | | Maximum 2D texture width. | +| 23 |*`cudaDevAttrMaxTexture2DHeight`* | | Maximum 2D texture height. | +| 24 |*`cudaDevAttrMaxTexture3DWidth`* | | Maximum 3D texture width. | +| 25 |*`cudaDevAttrMaxTexture3DHeight`* | | Maximum 3D texture height. | +| 26 |*`cudaDevAttrMaxTexture3DDepth`* | | Maximum 3D texture depth. | +| 27 |*`cudaDevAttrMaxTexture2DLayeredWidth`* | | Maximum 2D layered texture width. | +| 28 |*`cudaDevAttrMaxTexture2DLayeredHeight`* | | Maximum 2D layered texture height. | +| 29 |*`cudaDevAttrMaxTexture2DLayeredLayers`* | | Maximum layers in a 2D layered texture. | +| 30 |*`cudaDevAttrSurfaceAlignment`* | | Alignment requirement for surfaces. | +| 31 |*`cudaDevAttrConcurrentKernels`* |*`hipDeviceAttributeConcurrentKernels`* | Device can possibly execute multiple kernels concurrently. | +| 32 |*`cudaDevAttrEccEnabled`* | | Device has ECC support enabled. | +| 33 |*`cudaDevAttrPciBusId`* |*`hipDeviceAttributePciBusId`* | PCI bus ID of the device. | +| 34 |*`cudaDevAttrPciDeviceId`* |*`hipDeviceAttributePciDeviceId`* | PCI device ID of the device. | +| 35 |*`cudaDevAttrTccDriver`* | | Device is using TCC driver model. | +| 36 |*`cudaDevAttrMemoryClockRate`* |*`hipDeviceAttributeMemoryClockRate`* | Peak memory clock frequency in kilohertz. | +| 37 |*`cudaDevAttrGlobalMemoryBusWidth`* |*`hipDeviceAttributeMemoryBusWidth`* | Global memory bus width in bits. | +| 38 |*`cudaDevAttrL2CacheSize`* |*`hipDeviceAttributeL2CacheSize`* | Size of L2 cache in bytes. | +| 39 |*`cudaDevAttrMaxThreadsPerMultiProcessor`* |*`hipDeviceAttributeMaxThreadsPerMultiProcessor`* | Maximum resident threads per multiprocessor. | +| 40 |*`cudaDevAttrAsyncEngineCount`* | | Number of asynchronous engines. | +| 41 |*`cudaDevAttrUnifiedAddressing`* | | Device shares a unified address space with the host. | +| 42 |*`cudaDevAttrMaxTexture1DLayeredWidth`* | | Maximum 1D layered texture width. | +| 43 |*`cudaDevAttrMaxTexture1DLayeredLayers`* | | Maximum layers in a 1D layered texture. | +| 44 | | | *reserved* | +| 45 |*`cudaDevAttrMaxTexture2DGatherWidth`* | | Maximum 2D texture width if cudaArrayTextureGather is set. | +| 46 |*`cudaDevAttrMaxTexture2DGatherHeight`* | | Maximum 2D texture height if cudaArrayTextureGather is set. | +| 47 |*`cudaDevAttrMaxTexture3DWidthAlt`* | | Alternate maximum 3D texture width. | +| 48 |*`cudaDevAttrMaxTexture3DHeightAlt`* | | Alternate maximum 3D texture height. | +| 49 |*`cudaDevAttrMaxTexture3DDepthAlt`* | | Alternate maximum 3D texture depth. | +| 50 |*`cudaDevAttrPciDomainId`* | | PCI domain ID of the device. | +| 51 |*`cudaDevAttrTexturePitchAlignment`* | | Pitch alignment requirement for textures. | +| 52 |*`cudaDevAttrMaxTextureCubemapWidth`* | | Maximum cubemap texture width/height. | +| 53 |*`cudaDevAttrMaxTextureCubemapLayeredWidth`* | | Maximum cubemap layered texture width/height. | +| 54 |*`cudaDevAttrMaxTextureCubemapLayeredLayers`* | | Maximum layers in a cubemap layered texture. | +| 55 |*`cudaDevAttrMaxSurface1DWidth`* | | Maximum 1D surface width. | +| 56 |*`cudaDevAttrMaxSurface2DWidth`* | | Maximum 2D surface width. | +| 57 |*`cudaDevAttrMaxSurface2DHeight`* | | Maximum 2D surface height. | +| 58 |*`cudaDevAttrMaxSurface3DWidth`* | | Maximum 3D surface width. | +| 59 |*`cudaDevAttrMaxSurface3DHeight`* | | Maximum 3D surface height. | +| 60 |*`cudaDevAttrMaxSurface3DDepth`* | | Maximum 3D surface depth. | +| 61 |*`cudaDevAttrMaxSurface1DLayeredWidth`* | | Maximum 1D layered surface width. | +| 62 |*`cudaDevAttrMaxSurface1DLayeredLayers`* | | Maximum layers in a 1D layered surface. | +| 63 |*`cudaDevAttrMaxSurface2DLayeredWidth`* | | Maximum 2D layered surface width. | +| 64 |*`cudaDevAttrMaxSurface2DLayeredHeight`* | | Maximum 2D layered surface height. | +| 65 |*`cudaDevAttrMaxSurface2DLayeredLayers`* | | Maximum layers in a 2D layered surface. | +| 66 |*`cudaDevAttrMaxSurfaceCubemapWidth`* | | Maximum cubemap surface width. | +| 67 |*`cudaDevAttrMaxSurfaceCubemapLayeredWidth`* | | Maximum cubemap layered surface width. | +| 68 |*`cudaDevAttrMaxSurfaceCubemapLayeredLayers`* | | Maximum layers in a cubemap layered surface. | +| 69 |*`cudaDevAttrMaxTexture1DLinearWidth`* | | Maximum 1D linear texture width. | +| 70 |*`cudaDevAttrMaxTexture2DLinearWidth`* | | Maximum 2D linear texture width. | +| 71 |*`cudaDevAttrMaxTexture2DLinearHeight`* | | Maximum 2D linear texture height. | +| 72 |*`cudaDevAttrMaxTexture2DLinearPitch`* | | Maximum 2D linear texture pitch in bytes. | +| 73 |*`cudaDevAttrMaxTexture2DMipmappedWidth`* | | Maximum mipmapped 2D texture width. | +| 74 |*`cudaDevAttrMaxTexture2DMipmappedHeight`* | | Maximum mipmapped 2D texture height. | +| 75 |*`cudaDevAttrComputeCapabilityMajor`* |*`hipDeviceAttributeComputeCapabilityMajor`* | Major compute capability version number. | +| 76 |*`cudaDevAttrComputeCapabilityMinor`* |*`hipDeviceAttributeComputeCapabilityMinor`* | Minor compute capability version number. | +| 77 |*`cudaDevAttrMaxTexture1DMipmappedWidth`* | | Maximum mipmapped 1D texture width. | +| 78 |*`cudaDevAttrStreamPrioritiesSupported`* | | Device supports stream priorities. | +| 79 |*`cudaDevAttrGlobalL1CacheSupported`* | | Device supports caching globals in L1. | +| 80 |*`cudaDevAttrLocalL1CacheSupported`* | | Device supports caching locals in L1. | +| 81 |*`cudaDevAttrMaxSharedMemoryPerMultiprocessor`*|*`hipDeviceAttributeMaxSharedMemoryPerMultiprocessor`*| Maximum shared memory available per multiprocessor in bytes. | +| 82 |*`cudaDevAttrMaxRegistersPerMultiprocessor`* | | Maximum number of 32-bit registers available per multiprocessor. | +| 83 |*`cudaDevAttrManagedMemory`* | | Device can allocate managed memory on this system. | +| 84 |*`cudaDevAttrIsMultiGpuBoard`* |*`hipDeviceAttributeIsMultiGpuBoard`* | Device is on a multi-GPU board. | +| 85 |*`cudaDevAttrMultiGpuBoardGroupID`* | | Unique identifier for a group of devices on the same multi-GPU board. | +| enum |***`cudaError`*** |***`hipError_t`*** | CUDA Error types. | +| enum |***`cudaError_t`*** |***`hipError_t`*** | CUDA Error types. | +| 0 |*`cudaSuccess`* |*`hipSuccess`* | The API call returned with no errors. In the case of query calls, this can also mean that the operation being queried is complete.| +| 1 |*`cudaErrorMissingConfiguration`* | | The device function being invoked (usually via cudaLaunchKernel()) was not previously configured via the cudaConfigureCall() function.| +| 2 |*`cudaErrorMemoryAllocation`* |*`hipErrorMemoryAllocation`* | The API call failed because it was unable to allocate enough memory to perform the requested operation. | +| 3 |*`cudaErrorInitializationError`* |*`hipErrorInitializationError`* | The API call failed because the CUDA driver and runtime could not be initialized. | +| 4 |*`cudaErrorLaunchFailure`* | | An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointer and accessing out of bounds shared memory. The device cannot be used until cudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue using CUDA. | +| 5 |*`cudaErrorPriorLaunchFailure`* | | This indicated that a previous kernel launch failed. This was previously used for device emulation of kernel launches. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 6 |*`cudaErrorLaunchTimeout`* | | This indicates that the device kernel took too long to execute. This can only occur if timeouts are enabled - see the device property kernelExecTimeoutEnabled for more information. The device cannot be used until cudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue using CUDA.| +| 7 |*`cudaErrorLaunchOutOfResources`* |*`hipErrorLaunchOutOfResources`* | This indicates that a launch did not occur because it did not have appropriate resources. Although this error is similar to cudaErrorInvalidConfiguration, this error usually indicates that the user has attempted to pass too many arguments to the device kernel, or the kernel launch specifies too many threads for the kernel's register count.| +| 8 |*`cudaErrorInvalidDeviceFunction`* | | The requested device function does not exist or is not compiled for the proper device architecture. | +| 9 |*`cudaErrorInvalidConfiguration`* | | This indicates that a kernel launch is requesting resources that can never be satisfied by the current device. Requesting more shared memory per block than the device supports will trigger this error, as will requesting too many threads or blocks. See cudaDeviceProp for more device limitations.| +| 10 |*`cudaErrorInvalidDevice`* |*`hipErrorInvalidDevice`* | This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device. | +| 11 |*`cudaErrorInvalidValue`* |*`hipErrorInvalidValue`* | This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. | +| 12 |*`cudaErrorInvalidPitchValue`* | | This indicates that one or more of the pitch-related parameters passed to the API call is not within the acceptable range for pitch.| +| 13 |*`cudaErrorInvalidSymbol`* | | This indicates that the symbol name/identifier passed to the API call is not a valid name or identifier. | +| 14 |*`cudaErrorMapBufferObjectFailed`* | | This indicates that the buffer object could not be mapped. | +| 15 |*`cudaErrorUnmapBufferObjectFailed`* | | This indicates that the buffer object could not be unmapped. | +| 16 |*`cudaErrorInvalidHostPointer`* | | This indicates that at least one host pointer passed to the API call is not a valid host pointer. | +| 17 |*`cudaErrorInvalidDevicePointer`* |*`hipErrorInvalidDevicePointer`* | This indicates that at least one host pointer passed to the API call is not a valid host pointer. | +| 18 |*`cudaErrorInvalidTexture`* | | This indicates that the texture passed to the API call is not a valid texture. | +| 19 |*`cudaErrorInvalidTextureBinding`* | | This indicates that the texture binding is not valid. This occurs if you call cudaGetTextureAlignmentOffset() with an unbound texture.| +| 20 |*`cudaErrorInvalidChannelDescriptor`* | | This indicates that the channel descriptor passed to the API call is not valid. This occurs if the format is not one of the formats specified by cudaChannelFormatKind, or if one of the dimensions is invalid.| +| 21 |*`cudaErrorInvalidMemcpyDirection`* | | This indicates that the direction of the memcpy passed to the API call is not one of the types specified by cudaMemcpyKind. | +| 22 |*`cudaErrorAddressOfConstant`* | | This indicated that the user has taken the address of a constant variable, which was forbidden up until the CUDA 3.1 release. Deprecated This error return is deprecated as of CUDA 3.1. Variables in constant memory may now have their address taken by the runtime via cudaGetSymbolAddress().| +| 23 |*`cudaErrorTextureFetchFailed`* | | This indicated that a texture fetch was not able to be performed. This was previously used for device emulation of texture operations. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 24 |*`cudaErrorTextureNotBound`* | | This indicated that a texture was not bound for access. This was previously used for device emulation of texture operations. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 25 |*`cudaErrorSynchronizationError`* | | This indicated that a synchronization operation had failed. This was previously used for some device emulation functions. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 26 |*`cudaErrorInvalidFilterSetting`* | | This indicates that a non-float texture was being accessed with linear filtering. This is not supported by CUDA. | +| 27 |*`cudaErrorInvalidNormSetting`* | | This indicates that an attempt was made to read a non-float texture as a normalized float. This is not supported by CUDA. | +| 28 |*`cudaErrorMixedDeviceExecution`* | | Mixing of device and device emulation code was not allowed. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 29 |*`cudaErrorCudartUnloading`* | | This indicates that a CUDA Runtime API call cannot be executed because it is being called during process shut down, at a point in time after CUDA driver has been unloaded.| +| 30 |*`cudaErrorUnknown`* |*`hipErrorUnknown`* | This indicates that an unknown internal error has occurred. | +| 31 |*`cudaErrorNotYetImplemented`* | | This indicates that the API call is not yet implemented. Production releases of CUDA will never return this error. Deprecated This error return is deprecated as of CUDA 4.1.| +| 32 |*`cudaErrorMemoryValueTooLarge`* | | This indicated that an emulated device pointer exceeded the 32-bit address range. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 33 |*`cudaErrorInvalidResourceHandle`* |*`hipErrorInvalidResourceHandle`* | This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like cudaStream_t and cudaEvent_t.| +| 34 |*`cudaErrorNotReady`* |*`hipErrorNotReady`* | This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error, but must be indicated differently than cudaSuccess (which indicates completion). Calls that may return this value include cudaEventQuery() and cudaStreamQuery().| +| 35 |*`cudaErrorInsufficientDriver`* | | This indicates that the installed NVIDIA CUDA driver is older than the CUDA runtime library. This is not a supported configuration. Users should install an updated NVIDIA display driver to allow the application to run.| +| 36 |*`cudaErrorSetOnActiveProcess`* | | This indicates that the user has called cudaSetValidDevices(), cudaSetDeviceFlags(), cudaD3D9SetDirect3DDevice(), cudaD3D10SetDirect3DDevice, cudaD3D11SetDirect3DDevice(), or cudaVDPAUSetVDPAUDevice() after initializing the CUDA runtime by calling non-device management operations (allocating memory and launching kernels are examples of non-device management operations). This error can also be returned if using runtime/driver interoperability and there is an existing CUcontext active on the host thread.| +| 37 |*`cudaErrorInvalidSurface`* | | This indicates that the surface passed to the API call is not a valid surface. | +| 38 |*`cudaErrorNoDevice`* |*`hipErrorNoDevice`* | This indicates that no CUDA-capable devices were detected by the installed CUDA driver. | +| 39 |*`cudaErrorECCUncorrectable`* | | This indicates that an uncorrectable ECC error was detected during execution. | +| 40 |*`cudaErrorSharedObjectSymbolNotFound`* | | This indicates that a link to a shared object failed to resolve. | +| 41 |*`cudaErrorSharedObjectInitFailed`* | | This indicates that initialization of a shared object failed. | +| 42 |*`cudaErrorUnsupportedLimit`* |*`hipErrorUnsupportedLimit`* | This indicates that the cudaLimit passed to the API call is not supported by the active device. | +| 43 |*`cudaErrorDuplicateVariableName`* | | This indicates that multiple global or constant variables (across separate CUDA source files in the application) share the same string name.| +| 44 |*`cudaErrorDuplicateTextureName`* | | This indicates that multiple textures (across separate CUDA source files in the application) share the same string name. | +| 45 |*`cudaErrorDuplicateSurfaceName`* | | This indicates that multiple surfaces (across separate CUDA source files in the application) share the same string name. | +| 46 |*`cudaErrorDevicesUnavailable`* | | This indicates that all CUDA devices are busy or unavailable at the current time. Devices are often busy/unavailable due to use of cudaComputeModeExclusive, cudaComputeModeProhibited or when long running CUDA kernels have filled up the GPU and are blocking new work from starting. They can also be unavailable due to memory constraints on a device that already has active CUDA work being performed.| +| 47 |*`cudaErrorInvalidKernelImage`* | | This indicates that the device kernel image is invalid. | +| 48 |*`cudaErrorNoKernelImageForDevice`* | | This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies code generation options for a particular CUDA source file that do not include the corresponding device configuration.| +| 49 |*`cudaErrorIncompatibleDriverContext`* | | This indicates that the current context is not compatible with this the CUDA Runtime. This can only occur if you are using CUDA Runtime/Driver interoperability and have created an existing Driver context using the driver API. The Driver context may be incompatible either because the Driver context was created using an older version of the API, because the Runtime API call expects a primary driver context and the Driver context is not primary, or because the Driver context has been destroyed. Please see Interactions with the CUDA Driver API" for more information.| +| 50 |*`cudaErrorPeerAccessAlreadyEnabled`* |*`hipErrorPeerAccessAlreadyEnabled`* | This error indicates that a call to cudaDeviceEnablePeerAccess() is trying to re-enable peer addressing on from a context which has already had peer addressing enabled.| +| 51 |*`cudaErrorPeerAccessNotEnabled`* |*`hipErrorPeerAccessNotEnabled`* | This error indicates that a call to cudaDeviceEnablePeerAccess() is trying to re-enable peer addressing on from a context which has already had peer addressing enabled.| +| 52 | | | *reserved* | +| 53 | | | *reserved* | +| 54 |*`cudaErrorDeviceAlreadyInUse`* | | This indicates that a call tried to access an exclusive-thread device that is already in use by a different thread. | +| 55 |*`cudaErrorProfilerDisabled`* | | This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling tools like visual profiler.| +| 56 |*`cudaErrorProfilerNotInitialized`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to attempt to enable/disable the profiling via cudaProfilerStart or cudaProfilerStop without initialization.| +| 57 |*`cudaErrorProfilerAlreadyStarted`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cudaProfilerStart() when profiling is already enabled.| +| 58 |*`cudaErrorProfilerAlreadyStopped`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cudaProfilerStop() when profiling is already disabled.| +| 59 |*`cudaErrorAssert`* | | An assert triggered in device code during kernel execution. The device cannot be used again until cudaThreadExit() is called. All existing allocations are invalid and must be reconstructed if the program is to continue using CUDA.| +| 60 |*`cudaErrorTooManyPeers`* | | This error indicates that the hardware resources required to enable peer access have been exhausted for one or more of the devices passed to cudaEnablePeerAccess().| +| 61 |*`cudaErrorHostMemoryAlreadyRegistered`* | *`hipErrorHostMemoryAlreadyRegistered`* | This error indicates that the memory range passed to cudaHostRegister() has already been registered. | +| 62 |*`cudaErrorHostMemoryNotRegistered`* | *`hipErrorHostMemoryNotRegistered`* | This error indicates that the pointer passed to cudaHostUnregister() does not correspond to any currently registered memory region.| +| 63 |*`cudaErrorOperatingSystem`* | | This error indicates that an OS call failed. | +| 64 |*`cudaErrorPeerAccessUnsupported`* | | This error indicates that P2P access is not supported across the given devices. | +| 65 |*`cudaErrorLaunchMaxDepthExceeded`* | | This error indicates that a device runtime grid launch did not occur because the depth of the child grid would exceed the maximum supported number of nested grid launches.| +| 66 |*`cudaErrorLaunchFileScopedTex`* | | This error indicates that a grid launch did not occur because the kernel uses filescoped textures which are unsupported by the device runtime. Kernels launched via the device runtime only support textures created with the Texture Object API's.| +| 67 |*`cudaErrorLaunchFileScopedSurf`* | | This error indicates that a grid launch did not occur because the kernel uses filescoped surfaces which are unsupported by the device runtime. Kernels launched via the device runtime only support surfaces created with the Surface Object API's.| +| 68 |*`cudaErrorSyncDepthExceeded`* | | This error indicates that a call to cudaDeviceSynchronize made from the device runtime failed because the call was made at grid depth greater than than either the default (2 levels of grids) or user specified device limit cudaLimitDevRuntimeSyncDepth. To be able to synchronize on launched grids at a greater depth successfully, the maximum nested depth at which cudaDeviceSynchronize will be called must be specified with the cudaLimitDevRuntimeSyncDepth limit to the cudaDeviceSetLimit api before the host-side launch of a kernel using the device runtime. Keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory that cannot be used for user allocations.| +| 69 |*`cudaErrorLaunchPendingCountExceeded`* | | This error indicates that a device runtime grid launch failed because the launch would exceed the limit cudaLimitDevRuntimePendingLaunchCount. For this launch to proceed successfully, cudaDeviceSetLimit must be called to set the cudaLimitDevRuntimePendingLaunchCount to be higher than the upper bound of outstanding launches that can be issued to the device runtime. Keep in mind that raising the limit of pending device runtime launches will require the runtime to reserve device memory that cannot be used for user allocations.| +| 70 |*`cudaErrorNotPermitted`* | | This error indicates the attempted operation is not permitted. | +| 71 |*`cudaErrorNotSupported`* | | This error indicates the attempted operation is not supported on the current system or device. | +| 72 |*`cudaErrorHardwareStackError`* | | Device encountered an error in the call stack during kernel execution, possibly due to stack corruption or exceeding the stack size limit. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 73 |*`cudaErrorIllegalInstruction`* | | The device encountered an illegal instruction during kernel execution The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 74 |*`cudaErrorMisalignedAddress`* | | The device encountered a load or store instruction on a memory address which is not aligned. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 75 |*`cudaErrorInvalidAddressSpace`* | | While executing a kernel, the device encountered an instruction which can only operate on memory locations in certain address spaces (global, shared, or local), but was supplied a memory address not belonging to an allowed address space. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 76 |*`cudaErrorInvalidPc`* | | The device encountered an invalid program counter. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 77 |*`cudaErrorIllegalAddress`* | | The device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 78 |*`cudaErrorInvalidPtx`* | | A PTX compilation failed. The runtime may fall back to compiling PTX if an application does not contain a suitable binary for the current device.| +| 79 |*`cudaErrorInvalidGraphicsContext`* | | This indicates an error with the OpenGL or DirectX context. | +| 0x7f |*`cudaErrorStartupFailure`* | | This indicates an internal startup failure in the CUDA runtime. | +| 1000 |*`cudaErrorApiFailureBase`* | | Any unhandled CUDA driver error is added to this value and returned via the runtime. Production releases of CUDA should not return such errors. Deprecated This error return is deprecated as of CUDA 4.1.| +| enum |***`cudaFuncCache`*** |***`hipFuncCache_t`*** | CUDA function cache configurations. | +| 0 |*`cudaFuncCachePreferNone`* |*`hipFuncCachePreferNone`* | Default function cache configuration, no preference. | +| 1 |*`cudaFuncCachePreferShared`* |*`hipFuncCachePreferShared`* | Prefer larger shared memory and smaller L1 cache. | +| 2 |*`cudaFuncCachePreferL1`* |*`hipFuncCachePreferL1`* | Prefer larger L1 cache and smaller shared memory. | +| 3 |*`cudaFuncCachePreferEqual`* |*`hipFuncCachePreferEqual`* | Prefer equal size L1 cache and shared memory. | +| enum |***`cudaGraphicsCubeFace`*** | | CUDA graphics interop array indices for cube maps. | +| 0x00 |*`cudaGraphicsCubeFacePositiveX`* | | Positive X face of cubemap. | +| 0x01 |*`cudaGraphicsCubeFaceNegativeX`* | | Negative X face of cubemap. | +| 0x02 |*`cudaGraphicsCubeFacePositiveY`* | | Positive Y face of cubemap. | +| 0x03 |*`cudaGraphicsCubeFaceNegativeY`* | | Negative Y face of cubemap. | +| 0x04 |*`cudaGraphicsCubeFacePositiveZ`* | | Positive Z face of cubemap. | +| 0x05 |*`cudaGraphicsCubeFaceNegativeZ`* | | Negative Z face of cubemap. | +| enum |***`cudaGraphicsMapFlags`*** | | CUDA graphics interop map flags. | +| 0 |*`cudaGraphicsMapFlagsNone`* | | Default; Assume resource can be read/written. | +| 1 |*`cudaGraphicsMapFlagsReadOnly`* | | CUDA will not write to this resource. | +| 2 |*`cudaGraphicsMapFlagsWriteDiscard`* | | CUDA will only write to and will not read from this resource. | +| enum |***`cudaGraphicsRegisterFlags`*** | | CUDA graphics interop register flags. | +| 0 |*`cudaGraphicsRegisterFlagsNone`* | | Default. | +| 1 |*`cudaGraphicsRegisterFlagsReadOnly`* | | CUDA will not write to this resource. | +| 2 |*`cudaGraphicsRegisterFlagsWriteDiscard`* | | CUDA will only write to and will not read from this resource. | +| 4 |*`cudaGraphicsRegisterFlagsSurfaceLoadStore`* | | CUDA will bind this resource to a surface reference. | +| 8 |*`cudaGraphicsRegisterFlagsTextureGather`* | | CUDA will perform texture gather operations on this resource. | +| enum |***`cudaLimit`*** |***`hipLimit_t`*** | CUDA Limits. | +| 0x00 |*`cudaLimitStackSize`* | | GPU thread stack size. | +| 0x01 |*`cudaLimitPrintfFifoSize`* | | GPU printf/fprintf FIFO size. | +| 0x02 |*`cudaLimitMallocHeapSize`* |*`hipLimitMallocHeapSize`* | GPU malloc heap size. | +| 0x03 |*`cudaLimitDevRuntimeSyncDepth`* | | GPU device runtime synchronize depth. | +| 0x04 |*`cudaLimitDevRuntimePendingLaunchCount`* | | GPU device runtime pending launch count. | +| enum |***`cudaMemcpyKind`*** |***`hipMemcpyKind`*** | CUDA memory copy types. | +| 0 |*`cudaMemcpyHostToHost`* |*`hipMemcpyHostToHost`* | Host -> Host. | +| 1 |*`cudaMemcpyHostToDevice`* |*`hipMemcpyHostToDevice`* | Host -> Device. | +| 2 |*`cudaMemcpyDeviceToHost`* |*`hipMemcpyDeviceToHost`* | Device -> Host. | +| 3 |*`cudaMemcpyDeviceToDevice`* |*`hipMemcpyDeviceToDevice`* | Device -> Device. | +| 4 |*`cudaMemcpyDefault`* |*`hipMemcpyDefault`* | Default based unified virtual address space. | +| enum |***`cudaMemoryType`*** |***`hipMemoryType`*** | CUDA memory types. | +| 1 |*`cudaMemoryTypeHost`* |*`hipMemoryTypeHost`* | Host memory. | +| 2 |*`cudaMemoryTypeDevice`* |*`hipMemoryTypeDevice`* | Device memory. | +| enum |***`cudaResourceType`*** | | CUDA resource types. | +| 0 |*`cudaResourceTypeArray`* | | Array resource. | +| 1 |*`cudaResourceTypeMipmappedArray`* | | Mipmapped array resource. | +| 2 |*`cudaResourceTypeLinear`* | | Linear resource. | +| 3 |*`cudaResourceTypePitch2D`* | | Pitch 2D resource. | +| enum |***`cudaResourceViewFormat`*** | | CUDA texture resource view formats. | +| 0x00 |*`cudaResViewFormatNone`* | | No resource view format (use underlying resource format). | +| 0x01 |*`cudaResViewFormatUnsignedChar1`* | | 1 channel unsigned 8-bit integers. | +| 0x02 |*`cudaResViewFormatUnsignedChar2`* | | 2 channel unsigned 8-bit integers. | +| 0x03 |*`cudaResViewFormatUnsignedChar4`* | | 4 channel unsigned 8-bit integers. | +| 0x04 |*`cudaResViewFormatSignedChar1`* | | 1 channel signed 8-bit integers. | +| 0x05 |*`cudaResViewFormatSignedChar2`* | | 2 channel signed 8-bit integers. | +| 0x06 |*`cudaResViewFormatSignedChar4`* | | 4 channel signed 8-bit integers. | +| 0x07 |*`cudaResViewFormatUnsignedShort1`* | | 1 channel unsigned 16-bit integers. | +| 0x08 |*`cudaResViewFormatUnsignedShort2`* | | 2 channel unsigned 16-bit integers. | +| 0x09 |*`cudaResViewFormatUnsignedShort4`* | | 4 channel unsigned 16-bit integers. | +| 0x0a |*`cudaResViewFormatSignedShort1`* | | 1 channel signed 16-bit integers. | +| 0x0b |*`cudaResViewFormatSignedShort2`* | | 2 channel signed 16-bit integers. | +| 0x0c |*`cudaResViewFormatSignedShort4`* | | 4 channel signed 16-bit integers. | +| 0x0d |*`cudaResViewFormatUnsignedInt1`* | | 1 channel unsigned 32-bit integers. | +| 0x0e |*`cudaResViewFormatUnsignedInt2`* | | 2 channel unsigned 32-bit integers. | +| 0x0f |*`cudaResViewFormatUnsignedInt4`* | | 4 channel unsigned 32-bit integers. | +| 0x10 |*`cudaResViewFormatSignedInt1`* | | 1 channel signed 32-bit integers. | +| 0x11 |*`cudaResViewFormatSignedInt2`* | | 2 channel signed 32-bit integers. | +| 0x12 |*`cudaResViewFormatSignedInt4`* | | 4 channel signed 32-bit integers. | +| 0x13 |*`cudaResViewFormatHalf1`* | | 1 channel 16-bit floating point. | +| 0x14 |*`cudaResViewFormatHalf2`* | | 2 channel 16-bit floating point. | +| 0x15 |*`cudaResViewFormatHalf4`* | | 4 channel 16-bit floating point. | +| 0x16 |*`cudaResViewFormatFloat1`* | | 1 channel 32-bit floating point. | +| 0x17 |*`cudaResViewFormatFloat2`* | | 2 channel 32-bit floating point. | +| 0x18 |*`cudaResViewFormatFloat4`* | | 4 channel 32-bit floating point. | +| 0x19 |*`cudaResViewFormatUnsignedBlockCompressed1`* | | Block compressed 1. | +| 0x1a |*`cudaResViewFormatUnsignedBlockCompressed2`* | | Block compressed 2. | +| 0x1b |*`cudaResViewFormatUnsignedBlockCompressed3`* | | Block compressed 3. | +| 0x1c |*`cudaResViewFormatUnsignedBlockCompressed4`* | | Block compressed 4 unsigned. | +| 0x1d |*`cudaResViewFormatSignedBlockCompressed4`* | | Block compressed 4 signed. | +| 0x1e |*`cudaResViewFormatUnsignedBlockCompressed5`* | | Block compressed 5 unsigned. | +| 0x1f |*`cudaResViewFormatSignedBlockCompressed5`* | | Block compressed 5 signed. | +| 0x20 |*`cudaResViewFormatUnsignedBlockCompressed6H`* | | Block compressed 6 unsigned half-float. | +| 0x21 |*`cudaResViewFormatSignedBlockCompressed6H`* | | Block compressed 6 signed half-float. | +| 0x22 |*`cudaResViewFormatUnsignedBlockCompressed7`* | | Block compressed 7. | +| enum |***`cudaSharedMemConfig`*** |***`hipSharedMemConfig`*** | CUDA shared memory configuration. | +| 0 |*`cudaSharedMemBankSizeDefault`* |*`hipSharedMemBankSizeDefault`* | | +| 1 |*`cudaSharedMemBankSizeFourByte`* |*`hipSharedMemBankSizeFourByte`* | | +| 2 |*`cudaSharedMemBankSizeEightByte`* |*`hipSharedMemBankSizeEightByte`* | | +| enum |***`cudaSurfaceBoundaryMode`*** | | CUDA Surface boundary modes. | +| 0 |*`cudaBoundaryModeZero`* | | Zero boundary mode. | +| 1 |*`cudaBoundaryModeClamp`* | | Clamp boundary mode. | +| 2 |*`cudaBoundaryModeTrap`* | | Trap boundary mode. | +| enum |***`cudaSurfaceFormatMode`*** | | CUDA Surface format modes. | +| 0 |*`cudaFormatModeForced`* | | Forced format mode. | +| 1 |*`cudaFormatModeAuto`* | | Auto format mode. | +| enum |***`cudaTextureAddressMode`*** | | CUDA texture address modes. | +| 0 |*`cudaAddressModeWrap`* | | Wrapping address mode. | +| 1 |*`cudaAddressModeClamp`* | | Clamp to edge address mode. | +| 2 |*`cudaAddressModeMirror`* | | Mirror address mode. | +| 3 |*`cudaAddressModeBorder`* | | Border address mode. | +| enum |***`cudaTextureFilterMode`*** |***`hipTextureFilterMode`*** | Point filter mode. | +| 0 |*`cudaFilterModePoint`* |*`hipFilterModePoint`* | Linear filter mode. | +| 1 |*`cudaFilterModeLinear`* | | Clamp to edge address mode. | +| enum |***`cudaTextureReadMode`*** |***`hipTextureReadMode`*** | CUDA texture read modes. | +| 0 |*`cudaReadModeElementType`* |*`hipReadModeElementType`* | Read texture as specified element type. | +| 1 |*`cudaReadModeNormalizedFloat`* | | Read texture as normalized float. | +| struct | `cudaArray` | `hipArray` | CUDA array [opaque]. | +| typedef | `cudaArray_t` | `hipArray *` | CUDA array pointer. | +| typedef | `cudaArray_const_t` | `const hipArray *` | CUDA array (as source copy argument). | +| enum | `cudaError` | `hipError_t` | CUDA Error types. | +| typedef | `cudaError_t` | `hipError_t` | CUDA Error types. | +| typedef | `cudaEvent_t` | `hipEvent_t` | CUDA event types. | +| typedef | `cudaGraphicsResource_t` | | CUDA graphics resource types. | +| typedef | `cudaMipmappedArray_t` | | CUDA mipmapped array. | +| typedef | `cudaMipmappedArray_const_t` | | CUDA mipmapped array (as source argument). | +| enum |***`cudaOutputMode`*** | | CUDA Profiler Output modes. | +| 0x00 |*`cudaKeyValuePair`* | | Output mode Key-Value pair format. | +| 0x01 |*`cudaCSV`* | | Output mode Comma separated values format. | +| typedef | `cudaOutputMode_t` | | CUDA output file modes. | +| typedef | `cudaStream_t` | `hipStream_t` | CUDA stream. | +| typedef | `cudaSurfaceObject_t` | | An opaque value that represents a CUDA Surface object. | +| typedef | `cudaTextureObject_t` | | An opaque value that represents a CUDA texture object. | +| typedef | `CUuuid_stcudaUUID_t` | | CUDA UUID types. | +| define | `CUDA_IPC_HANDLE_SIZE` | | CUDA IPC Handle Size. | +| define | `cudaArrayCubemap` | | Must be set in cudaMalloc3DArray to create a cubemap CUDA array. | +| define | `cudaArrayDefault` | | Default CUDA array allocation flag. | +| define | `cudaArrayLayered` | | Must be set in cudaMalloc3DArray to create a layered CUDA array. | +| define | `cudaArraySurfaceLoadStore` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA array. | +| define | `cudaArrayTextureGather` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather operations on the CUDA array. | +| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. Deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync. | +| define | `cudaDeviceLmemResizeToMax` | | Device flag - Keep local memory allocation after launch. | +| define | `cudaDeviceMapHost` | | Device flag - Support mapped pinned allocations. | +| define | `cudaDeviceMask` | | Device flags mask. | +| define | `cudaDevicePropDontCare` | | Empty device properties. | +| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` | Device flag - Automatic scheduling. | +| define | `cudaDeviceScheduleBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. | +| define | `cudaDeviceScheduleMask` | `hipDeviceScheduleMask` | Device schedule flags mask. | +| define | `cudaDeviceScheduleSpin` | `hipDeviceScheduleSpin` | Device flag - Spin default scheduling. | +| define | `cudaDeviceScheduleYield` | `hipDeviceScheduleYield` | Device flag - Yield default scheduling. | +| define | `cudaEventDefault` | `hipEventDefault` | Default event flag. | +| define | `cudaEventDisableTiming` | `hipEventDisableTiming` | Event will not record timing data. | +| define | `cudaEventInterprocess` | `hipEventInterprocess` | Event is suitable for interprocess use. cudaEventDisableTiming must be set. | +| define | `cudaHostAllocDefault` | `hipHostMallocDefault` | Default page-locked allocation flag. | +| define | `cudaHostAllocMapped` | `hipHostMallocMapped` | Map allocation into device space. | +| define | `cudaHostAllocPortable` | `hipHostMallocPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaHostAllocWriteCombined` | `hipHostMallocWriteCombined` | Write-combined memory. | +| define | `cudaHostRegisterDefault` | `hipHostRegisterDefault` | Default host memory registration flag. | +| define | `cudaHostRegisterIoMemory` | `hipHostRegisterIoMemory` | Memory-mapped I/O space. | +| define | `cudaHostRegisterMapped` | `hipHostRegisterMapped` | Map registered memory into device space. | +| define | `cudaHostRegisterPortable` | `hipHostRegisterPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaIpcMemLazyEnablePeerAccess` | `hipIpcMemLazyEnablePeerAccess` | Automatically enable peer access between remote devices as needed. | +| define | `cudaMemAttachGlobal` | | Memory can be accessed by any stream on any device. | +| define | `cudaMemAttachHost` | | Memory cannot be accessed by any stream on any device. | +| define | `cudaMemAttachSingle` | | Memory can only be accessed by a single stream on the associated device. | +| define | `cudaOccupancyDefault` | | Default behavior. | +| define | `cudaOccupancyDisableCachingOverride` | | Assume global caching is enabled and cannot be automatically turned off. | +| define | `cudaPeerAccessDefault` | | Default peer addressing enable flag. | +| define | `cudaStreamDefault` | `hipStreamDefault` | Default stream flag. | +| define | `cudaStreamLegacy` | | Default stream flag. | +| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` | Stream does not synchronize with stream 0 (the NULL stream). | +| define | `cudaStreamPerThread` | | Per-thread stream handle. | diff --git a/projects/hip/docs/markdown/device_md_gen.py b/projects/hip/docs/markdown/device_md_gen.py new file mode 100644 index 0000000000..995782189f --- /dev/null +++ b/projects/hip/docs/markdown/device_md_gen.py @@ -0,0 +1,508 @@ +""" +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +""" + +""" +1. This files uses Python3 to run + +List of device functions: +acosf +acoshf +asinf +asinhf +atan2f +atanf +atanhf +cbrtf +ceilf +copysignf +cosf +coshf +cospif +cyl_bessel_i0f +cyl_bessel_i1f +erfcf +erfcinvf +erfcxf +erff +erfinvf +exp10f +exp2f +expf +expm1f +fabsf +fdimf +fdividef +floorf +fmaf +fmaxf +fminf +fmodf +frexpf +hypotf +ilogbf +isfinite +isinf +isnan +j0f +j1f +jnf +ldexpf +lgammaf +llrintf +llroundf +log10f +log1pf +logbf +lrintf +lroundf +modff +nanf +nearbyintf +nextafterf +norm3df +norm4df +normcdff +normcdfinvf +normf +powf +rcbrtf +remainderf +remquof +rhypotf +rintf +rnorm3df +rnorm4df +rnormf +roundf +rsqrtf +scalblnf +scalbnf +signbit +sincosf +sincospif +sinf +sinhf +sinpif +sqrtf +tanf +tanhf +tgammaf +truncf +y0f +y1f +ynf +acos +acosh +asin +asinh +atan +atan2 +atanh +cbrt +ceil +copysign +cos +cosh +cospi +cyl_bessel_i0 +cyl_bessel_i1 +erf +erfc +erfcinv +erfcx +erfinv +exp +exp10 +exp2 +expm1 +fabs +fdim +floor +fma +fmax +fmin +fmod +frexp +hypot +ilogb +isfinite +isinf +isnan +j0 +j1 +jn +ldexp +lgamma +llrint +llround +log +log10 +log1p +log2 +logb +lrint +lround +modf +nan +nearbyint +nextafter +norm +norm3d +norm4d +normcdf +normcdfinv +pow +rcbrt +remainder +remquo +rhypot +rint +rnorm +rnorm3d +rnorm4d +round +rsqrt +scalbln +scalbn +signbit +sin +sincos +sincospi +sinh +sinpi +sqrt +tan +tanh +tgamma +trunc +y0 +y1 +yn +__cosf +__exp10f +__expf +__fadd_rd +__fadd_rn +__fadd_ru +__fadd_rz +__fdiv_rd +__fdiv_rn +__fdiv_ru +__fdiv_rz +__fdividef +__fmaf_rd +__fmaf_rn +__fmaf_ru +__fmaf_rz +__fmul_rd +__fmul_rn +__fmul_ru +__fmul_rz +__frcp_rd +__frcp_rn +__frcp_ru +__frcp_rz +__frsqrt_rn +__fsqrt_rd +__fsqrt_rn +__fsqrt_ru +__fsqrt_rz +__fsub_rd +__fsub_rn +__fsub_ru +__log10f +__log2f +__logf +__powf +__saturatef +__sincosf +__sinf +__tanf +__dadd_rd +__dadd_rn +__dadd_ru +__dadd_rz +__ddiv_rd +__ddiv_rn +__ddiv_ru +__ddiv_rz +__dmul_rd +__dmul_rn +__dmul_ru +__dmul_rz +__drcp_rd +__drcp_rn +__drcp_ru +__drcp_rz +__dsqrt_rd +__dsqrt_rn +__dsqrt_ru +__dsqrt_rz +__dsub_rd +__dsub_rn +__dsub_ru +__dsub_rz +__fma_rd +__fma_rn +__fma_ru +__fma_rz +__brev +__brevll +__byte_perm +__clz +__clzll +__ffs +__ffsll +__hadd +__mul24 +__mul64hi +__mulhi +__popc +__popcll +__rhadd +__sad +__uhadd +__umul24 +__umul64hi +__umulhi +__urhadd +__usad +__double2float_rd +__double2float_rn +__double2float_ru +__double2float_rz +__double2hiint +__double2int_rd +__double2int_rn +__double2int_ru +__double2int_rz +__double2ll_rd +__double2ll_rn +__double2ll_ru +__double2ll_rz +__double2loint +__double2uint_rd +__double2uint_rn +__double2uint_ru +__double2uint_rz +__double2ull_rd +__double2ull_rn +__double2ull_ru +__double2ull_rz +__double_as_longlong +__float2half_rn +__half2float +__float2half_rn +__half2float +__float2int_rd +__float2int_rn +__float2int_ru +__float2int_rz +__float2ll_rd +__float2ll_rn +__float2ll_ru +__float2ll_rz +__float2uint_rd +__float2uint_rn +__float2uint_ru +__float2uint_rz +__float2ull_rd +__float2ull_rn +__float2ull_ru +__float2ull_rz +__float_as_int +__float_as_uint +__hiloint2double +__int2double_rn +__int2float_rd +__int2float_rn +__int2float_ru +__int2float_rz +__int_as_float +__ll2double_rd +__ll2double_rn +__ll2double_ru +__ll2double_rz +__ll2float_rd +__ll2float_rn +__ll2float_ru +__ll2float_rz +__longlong_as_double +__uint2double_rn +__uint2float_rd +__uint2float_rn +__uint2float_ru +__uint2float_rz +__uint_as_float +__ull2double_rd +__ull2double_rn +__ull2double_ru +__ull2double_rz +__ull2float_rd +__ull2float_rn +__ull2float_ru +__ull2float_rz +__heq +__hge +__hgt +__hisinf +__hisnan +__hle +__hlt +__hne +__hbeq2 +__hbge2 +__hbgt2 +__hble2 +__hblt2 +__hbne2 +__heq2 +__hge2 +__hgt2 +__hisnan2 +__hle2 +__hlt2 +__hne2 +__float22half2_rn +__float2half +__float2half2_rn +__float2half_rd +__float2half_rn +__float2half_ru +__float2half_rz +__floats2half2_rn +__half22float2 +__half2float +half2half2 +__half2int_rd +__half2int_rn +__half2int_ru +__half2int_rz +__half2ll_rd +__half2ll_rn +__half2ll_ru +__half2ll_rz +__half2short_rd +__half2short_rn +__half2short_ru +__half2short_rz +__half2uint_rd +__half2uint_rn +__half2uint_ru +__half2uint_rz +__half2ull_rd +__half2ull_rn +__half2ull_ru +__half2ull_rz +__half2ushort_rd +__half2ushort_rn +__half2ushort_ru +__half2ushort_rz +__half_as_short +__half_as_ushort +__halves2half2 +__high2float +__high2half +__high2half2 +__highs2half2 +__int2half_rd +__int2half_rn +__int2half_ru +__int2half_rz +__ll2half_rd +__ll2half_rn +__ll2half_ru +__ll2half_rz +__low2float +__low2half +__low2half2 +__low2half2 +__lowhigh2highlow +__lows2half2 +__short2half_rd +__short2half_rn +__short2half_ru +__short2half_rz +__uint2half_rd +__uint2half_rn +__uint2half_ru +__uint2half_rz +__ull2half_rd +__ull2half_rn +__ull2half_ru +__ull2half_rz +__ushort2half_rd +__ushort2half_rn +__ushort2half_ru +__ushort2half_rz +__ushort_as_half +""" +# The dictionary is to place description of each device function. Expand it to all the device functions +deviceFuncDesc = {'acosf': "This function returns floating point of arc cosine from a floating point input"} + +fnames = ["../../include/hip/hcc_detail/math_functions.h","../../include/hip/hcc_detail/device_functions.h","../../include/hip/hcc_detail/hip_fp16.h"] +markdownFileName = "./hip-math-api.md" + +preamble = "# HIP MATH APIs Documentation \n"+\ +"HIP supports most of the device functions supported by CUDA. Way to find the unsupported one is to search for the function and check its description\n" + \ +"Note: This document is not human generated. Any changes to this file will be discarded. Please make changes to Python3 script docs/markdown/device_md_gen.py\n\n" + \ +"## For Developers \n" + \ +"If you add or fixed a device function, make sure to add a signature of the function and definition later.\n" + \ +"For example, if you want to add `__device__ float __dotf(float4, float4)`, which does a dot product on 4 float vector components \n" + \ +"The way to add to the header is, \n" + \ +"```cpp \n" + \ +"__device__ static float __dotf(float4, float4); \n" + \ +"/*Way down in the file....*/\n" + \ +"__device__ static inline float __dotf(float4 x, float4 y) { \n" + \ +" /*implementation*/\n}\n" + \ +"```\n\n" + \ +"This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning)\n\n" + \ +"The next step would be to add Description to `deviceFuncDesc` dictionary in python script.\n" + \ +"From the above example, it can be writtern as,\n`deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'`\n\n" + +def generateSnippet(name, description, signature): + return "### " + name + "\n" + \ + "```cpp \n" + signature + "\n```\n" + \ + "**Description:** " + description + "\n\n\n" + +def getName(line): + l1 = line.split('(') + l2 = l1[0].split(' ') + return l2[-1] + +with open(markdownFileName, 'w') as mdfd: + mdfd.truncate() + mdfd.write(preamble) + for fname in fnames: + with open(fname) as fd: + lines = fd.readlines() + for line in lines: + if line.find('HIP_FAST_MATH') != -1: + break; + if line.find('__device__') != -1 and line.find(';') != -1 and line.find('hip') == -1: + name = getName(line) + if line.find('//') == -1: + if name in deviceFuncDesc: + mdfd.write(generateSnippet(name, deviceFuncDesc[name], line)) + else: + mdfd.write(generateSnippet(name, "Supported", line)) + else: + mdfd.write(generateSnippet(name, "**NOT Supported**", line)) + fd.close() + mdfd.close() diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md new file mode 100644 index 0000000000..37efafbbbf --- /dev/null +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -0,0 +1,3838 @@ +# HIP MATH APIs Documentation +HIP supports most of the device functions supported by CUDA. Way to find the unsupported one is to search for the function and check its description +Note: This document is not human generated. Any changes to this file will be discarded. Please make changes to Python3 script docs/markdown/device_md_gen.py + +## For Developers +If you add or fixed a device function, make sure to add a signature of the function and definition later. +For example, if you want to add `__device__ float __dotf(float4, float4)`, which does a dot product on 4 float vector components +The way to add to the header is, +```cpp +__device__ static float __dotf(float4, float4); +/*Way down in the file....*/ +__device__ static inline float __dotf(float4 x, float4 y) { + /*implementation*/ +} +``` + +This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning) + +The next step would be to add Description to `deviceFuncDesc` dictionary in python script. +From the above example, it can be writtern as, +`deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'` + +### acosf +```cpp +__device__ float acosf(float x); + +``` +**Description:** This function returns floating point of arc cosine from a floating point input + + +### acoshf +```cpp +__device__ float acoshf(float x); + +``` +**Description:** Supported + + +### asinf +```cpp +__device__ float asinf(float x); + +``` +**Description:** Supported + + +### asinhf +```cpp +__device__ float asinhf(float x); + +``` +**Description:** Supported + + +### atan2f +```cpp +__device__ float atan2f(float y, float x); + +``` +**Description:** Supported + + +### atanf +```cpp +__device__ float atanf(float x); + +``` +**Description:** Supported + + +### atanhf +```cpp +__device__ float atanhf(float x); + +``` +**Description:** Supported + + +### cbrtf +```cpp +__device__ float cbrtf(float x); + +``` +**Description:** Supported + + +### ceilf +```cpp +__device__ float ceilf(float x); + +``` +**Description:** Supported + + +### copysignf +```cpp +__device__ float copysignf(float x, float y); + +``` +**Description:** Supported + + +### cosf +```cpp +__device__ float cosf(float x); + +``` +**Description:** Supported + + +### coshf +```cpp +__device__ float coshf(float x); + +``` +**Description:** Supported + + +### cospif +```cpp +__device__ float cospif(float x); + +``` +**Description:** Supported + + +### cyl_bessel_i0f +```cpp +//__device__ float cyl_bessel_i0f(float x); + +``` +**Description:** **NOT Supported** + + +### cyl_bessel_i1f +```cpp +//__device__ float cyl_bessel_i1f(float x); + +``` +**Description:** **NOT Supported** + + +### erfcf +```cpp +__device__ float erfcf(float x); + +``` +**Description:** Supported + + +### erfcinvf +```cpp +__device__ float erfcinvf(float y); + +``` +**Description:** Supported + + +### erfcxf +```cpp +__device__ float erfcxf(float x); + +``` +**Description:** Supported + + +### erff +```cpp +__device__ float erff(float x); + +``` +**Description:** Supported + + +### erfinvf +```cpp +__device__ float erfinvf(float y); + +``` +**Description:** Supported + + +### exp10f +```cpp +__device__ float exp10f(float x); + +``` +**Description:** Supported + + +### exp2f +```cpp +__device__ float exp2f(float x); + +``` +**Description:** Supported + + +### expf +```cpp +__device__ float expf(float x); + +``` +**Description:** Supported + + +### expm1f +```cpp +__device__ float expm1f(float x); + +``` +**Description:** Supported + + +### fabsf +```cpp +__device__ float fabsf(float x); + +``` +**Description:** Supported + + +### fdimf +```cpp +__device__ float fdimf(float x, float y); + +``` +**Description:** Supported + + +### fdividef +```cpp +__device__ float fdividef(float x, float y); + +``` +**Description:** Supported + + +### floorf +```cpp +__device__ float floorf(float x); + +``` +**Description:** Supported + + +### fmaf +```cpp +__device__ float fmaf(float x, float y, float z); + +``` +**Description:** Supported + + +### fmaxf +```cpp +__device__ float fmaxf(float x, float y); + +``` +**Description:** Supported + + +### fminf +```cpp +__device__ float fminf(float x, float y); + +``` +**Description:** Supported + + +### fmodf +```cpp +__device__ float fmodf(float x, float y); + +``` +**Description:** Supported + + +### frexpf +```cpp +//__device__ float frexpf(float x, int* nptr); + +``` +**Description:** **NOT Supported** + + +### hypotf +```cpp +__device__ float hypotf(float x, float y); + +``` +**Description:** Supported + + +### ilogbf +```cpp +__device__ float ilogbf(float x); + +``` +**Description:** Supported + + +### isfinite +```cpp +__device__ int isfinite(float a); + +``` +**Description:** Supported + + +### isinf +```cpp +__device__ unsigned isinf(float a); + +``` +**Description:** Supported + + +### isnan +```cpp +__device__ unsigned isnan(float a); + +``` +**Description:** Supported + + +### j0f +```cpp +__device__ float j0f(float x); + +``` +**Description:** Supported + + +### j1f +```cpp +__device__ float j1f(float x); + +``` +**Description:** Supported + + +### jnf +```cpp +__device__ float jnf(int n, float x); + +``` +**Description:** Supported + + +### ldexpf +```cpp +__device__ float ldexpf(float x, int exp); + +``` +**Description:** Supported + + +### lgammaf +```cpp +//__device__ float lgammaf(float x); + +``` +**Description:** **NOT Supported** + + +### llrintf +```cpp +__device__ long long int llrintf(float x); + +``` +**Description:** Supported + + +### llroundf +```cpp +__device__ long long int llroundf(float x); + +``` +**Description:** Supported + + +### log10f +```cpp +__device__ float log10f(float x); + +``` +**Description:** Supported + + +### log1pf +```cpp +__device__ float log1pf(float x); + +``` +**Description:** Supported + + +### logbf +```cpp +__device__ float logbf(float x); + +``` +**Description:** Supported + + +### lrintf +```cpp +__device__ long int lrintf(float x); + +``` +**Description:** Supported + + +### lroundf +```cpp +__device__ long int lroundf(float x); + +``` +**Description:** Supported + + +### modff +```cpp +//__device__ float modff(float x, float *iptr); + +``` +**Description:** **NOT Supported** + + +### nanf +```cpp +__device__ float nanf(const char* tagp); + +``` +**Description:** Supported + + +### nearbyintf +```cpp +__device__ float nearbyintf(float x); + +``` +**Description:** Supported + + +### nextafterf +```cpp +//__device__ float nextafterf(float x, float y); + +``` +**Description:** **NOT Supported** + + +### norm3df +```cpp +__device__ float norm3df(float a, float b, float c); + +``` +**Description:** Supported + + +### norm4df +```cpp +__device__ float norm4df(float a, float b, float c, float d); + +``` +**Description:** Supported + + +### normcdff +```cpp +__device__ float normcdff(float y); + +``` +**Description:** Supported + + +### normcdfinvf +```cpp +__device__ float normcdfinvf(float y); + +``` +**Description:** Supported + + +### normf +```cpp +__device__ float normf(int dim, const float *a); + +``` +**Description:** Supported + + +### powf +```cpp +__device__ float powf(float x, float y); + +``` +**Description:** Supported + + +### rcbrtf +```cpp +__device__ float rcbrtf(float x); + +``` +**Description:** Supported + + +### remainderf +```cpp +__device__ float remainderf(float x, float y); + +``` +**Description:** Supported + + +### remquof +```cpp +__device__ float remquof(float x, float y, int *quo); + +``` +**Description:** Supported + + +### rhypotf +```cpp +__device__ float rhypotf(float x, float y); + +``` +**Description:** Supported + + +### rintf +```cpp +__device__ float rintf(float x); + +``` +**Description:** Supported + + +### rnorm3df +```cpp +__device__ float rnorm3df(float a, float b, float c); + +``` +**Description:** Supported + + +### rnorm4df +```cpp +__device__ float rnorm4df(float a, float b, float c, float d); + +``` +**Description:** Supported + + +### rnormf +```cpp +__device__ float rnormf(int dim, const float* a); + +``` +**Description:** Supported + + +### roundf +```cpp +__device__ float roundf(float x); + +``` +**Description:** Supported + + +### rsqrtf +```cpp +__device__ float rsqrtf(float x); + +``` +**Description:** Supported + + +### scalblnf +```cpp +__device__ float scalblnf(float x, long int n); + +``` +**Description:** Supported + + +### scalbnf +```cpp +__device__ float scalbnf(float x, int n); + +``` +**Description:** Supported + + +### signbit +```cpp +__device__ int signbit(float a); + +``` +**Description:** Supported + + +### sincosf +```cpp +__device__ void sincosf(float x, float *sptr, float *cptr); + +``` +**Description:** Supported + + +### sincospif +```cpp +__device__ void sincospif(float x, float *sptr, float *cptr); + +``` +**Description:** Supported + + +### sinf +```cpp +__device__ float sinf(float x); + +``` +**Description:** Supported + + +### sinhf +```cpp +__device__ float sinhf(float x); + +``` +**Description:** Supported + + +### sinpif +```cpp +__device__ float sinpif(float x); + +``` +**Description:** Supported + + +### sqrtf +```cpp +__device__ float sqrtf(float x); + +``` +**Description:** Supported + + +### tanf +```cpp +__device__ float tanf(float x); + +``` +**Description:** Supported + + +### tanhf +```cpp +__device__ float tanhf(float x); + +``` +**Description:** Supported + + +### tgammaf +```cpp +__device__ float tgammaf(float x); + +``` +**Description:** Supported + + +### truncf +```cpp +__device__ float truncf(float x); + +``` +**Description:** Supported + + +### y0f +```cpp +__device__ float y0f(float x); + +``` +**Description:** Supported + + +### y1f +```cpp +__device__ float y1f(float x); + +``` +**Description:** Supported + + +### ynf +```cpp +__device__ float ynf(int n, float x); + +``` +**Description:** Supported + + +### acos +```cpp +__device__ double acos(double x); + +``` +**Description:** Supported + + +### acosh +```cpp +__device__ double acosh(double x); + +``` +**Description:** Supported + + +### asin +```cpp +__device__ double asin(double x); + +``` +**Description:** Supported + + +### asinh +```cpp +__device__ double asinh(double x); + +``` +**Description:** Supported + + +### atan +```cpp +__device__ double atan(double x); + +``` +**Description:** Supported + + +### atan2 +```cpp +__device__ double atan2(double y, double x); + +``` +**Description:** Supported + + +### atanh +```cpp +__device__ double atanh(double x); + +``` +**Description:** Supported + + +### cbrt +```cpp +__device__ double cbrt(double x); + +``` +**Description:** Supported + + +### ceil +```cpp +__device__ double ceil(double x); + +``` +**Description:** Supported + + +### copysign +```cpp +__device__ double copysign(double x, double y); + +``` +**Description:** Supported + + +### cos +```cpp +__device__ double cos(double x); + +``` +**Description:** Supported + + +### cosh +```cpp +__device__ double cosh(double x); + +``` +**Description:** Supported + + +### cospi +```cpp +__device__ double cospi(double x); + +``` +**Description:** Supported + + +### cyl_bessel_i0 +```cpp +//__device__ double cyl_bessel_i0(double x); + +``` +**Description:** **NOT Supported** + + +### cyl_bessel_i1 +```cpp +//__device__ double cyl_bessel_i1(double x); + +``` +**Description:** **NOT Supported** + + +### erf +```cpp +__device__ double erf(double x); + +``` +**Description:** Supported + + +### erfc +```cpp +__device__ double erfc(double x); + +``` +**Description:** Supported + + +### erfcinv +```cpp +__device__ double erfcinv(double y); + +``` +**Description:** Supported + + +### erfcx +```cpp +__device__ double erfcx(double x); + +``` +**Description:** Supported + + +### erfinv +```cpp +__device__ double erfinv(double x); + +``` +**Description:** Supported + + +### exp +```cpp +__device__ double exp(double x); + +``` +**Description:** Supported + + +### exp10 +```cpp +__device__ double exp10(double x); + +``` +**Description:** Supported + + +### exp2 +```cpp +__device__ double exp2(double x); + +``` +**Description:** Supported + + +### expm1 +```cpp +__device__ double expm1(double x); + +``` +**Description:** Supported + + +### fabs +```cpp +__device__ double fabs(double x); + +``` +**Description:** Supported + + +### fdim +```cpp +__device__ double fdim(double x, double y); + +``` +**Description:** Supported + + +### floor +```cpp +__device__ double floor(double x); + +``` +**Description:** Supported + + +### fma +```cpp +__device__ double fma(double x, double y, double z); + +``` +**Description:** Supported + + +### fmax +```cpp +__device__ double fmax(double x, double y); + +``` +**Description:** Supported + + +### fmin +```cpp +__device__ double fmin(double x, double y); + +``` +**Description:** Supported + + +### fmod +```cpp +__device__ double fmod(double x, double y); + +``` +**Description:** Supported + + +### frexp +```cpp +//__device__ double frexp(double x, int *nptr); + +``` +**Description:** **NOT Supported** + + +### hypot +```cpp +__device__ double hypot(double x, double y); + +``` +**Description:** Supported + + +### ilogb +```cpp +__device__ double ilogb(double x); + +``` +**Description:** Supported + + +### isfinite +```cpp +__device__ int isfinite(double x); + +``` +**Description:** Supported + + +### isinf +```cpp +__device__ unsigned isinf(double x); + +``` +**Description:** Supported + + +### isnan +```cpp +__device__ unsigned isnan(double x); + +``` +**Description:** Supported + + +### j0 +```cpp +__device__ double j0(double x); + +``` +**Description:** Supported + + +### j1 +```cpp +__device__ double j1(double x); + +``` +**Description:** Supported + + +### jn +```cpp +__device__ double jn(int n, double x); + +``` +**Description:** Supported + + +### ldexp +```cpp +__device__ double ldexp(double x, int exp); + +``` +**Description:** Supported + + +### lgamma +```cpp +__device__ double lgamma(double x); + +``` +**Description:** Supported + + +### llrint +```cpp +__device__ long long llrint(double x); + +``` +**Description:** Supported + + +### llround +```cpp +__device__ long long llround(double x); + +``` +**Description:** Supported + + +### log +```cpp +__device__ double log(double x); + +``` +**Description:** Supported + + +### log10 +```cpp +__device__ double log10(double x); + +``` +**Description:** Supported + + +### log1p +```cpp +__device__ double log1p(double x); + +``` +**Description:** Supported + + +### log2 +```cpp +__device__ double log2(double x); + +``` +**Description:** Supported + + +### logb +```cpp +__device__ double logb(double x); + +``` +**Description:** Supported + + +### lrint +```cpp +__device__ long int lrint(double x); + +``` +**Description:** Supported + + +### lround +```cpp +__device__ long int lround(double x); + +``` +**Description:** Supported + + +### modf +```cpp +//__device__ double modf(double x, double *iptr); + +``` +**Description:** **NOT Supported** + + +### nan +```cpp +__device__ double nan(const char* tagp); + +``` +**Description:** Supported + + +### nearbyint +```cpp +__device__ double nearbyint(double x); + +``` +**Description:** Supported + + +### nextafter +```cpp +__device__ double nextafter(double x, double y); + +``` +**Description:** Supported + + +### norm +```cpp +__device__ double norm(int dim, const double* t); + +``` +**Description:** Supported + + +### norm3d +```cpp +__device__ double norm3d(double a, double b, double c); + +``` +**Description:** Supported + + +### norm4d +```cpp +__device__ double norm4d(double a, double b, double c, double d); + +``` +**Description:** Supported + + +### normcdf +```cpp +__device__ double normcdf(double y); + +``` +**Description:** Supported + + +### normcdfinv +```cpp +__device__ double normcdfinv(double y); + +``` +**Description:** Supported + + +### pow +```cpp +__device__ double pow(double x, double y); + +``` +**Description:** Supported + + +### rcbrt +```cpp +__device__ double rcbrt(double x); + +``` +**Description:** Supported + + +### remainder +```cpp +__device__ double remainder(double x, double y); + +``` +**Description:** Supported + + +### remquo +```cpp +//__device__ double remquo(double x, double y, int *quo); + +``` +**Description:** **NOT Supported** + + +### rhypot +```cpp +__device__ double rhypot(double x, double y); + +``` +**Description:** Supported + + +### rint +```cpp +__device__ double rint(double x); + +``` +**Description:** Supported + + +### rnorm +```cpp +__device__ double rnorm(int dim, const double* t); + +``` +**Description:** Supported + + +### rnorm3d +```cpp +__device__ double rnorm3d(double a, double b, double c); + +``` +**Description:** Supported + + +### rnorm4d +```cpp +__device__ double rnorm4d(double a, double b, double c, double d); + +``` +**Description:** Supported + + +### round +```cpp +__device__ double round(double x); + +``` +**Description:** Supported + + +### rsqrt +```cpp +__device__ double rsqrt(double x); + +``` +**Description:** Supported + + +### scalbln +```cpp +__device__ double scalbln(double x, long int n); + +``` +**Description:** Supported + + +### scalbn +```cpp +__device__ double scalbn(double x, int n); + +``` +**Description:** Supported + + +### signbit +```cpp +__device__ int signbit(double a); + +``` +**Description:** Supported + + +### sin +```cpp +__device__ double sin(double a); + +``` +**Description:** Supported + + +### sincos +```cpp +__device__ void sincos(double x, double *sptr, double *cptr); + +``` +**Description:** Supported + + +### sincospi +```cpp +__device__ void sincospi(double x, double *sptr, double *cptr); + +``` +**Description:** Supported + + +### sinh +```cpp +__device__ double sinh(double x); + +``` +**Description:** Supported + + +### sinpi +```cpp +__device__ double sinpi(double x); + +``` +**Description:** Supported + + +### sqrt +```cpp +__device__ double sqrt(double x); + +``` +**Description:** Supported + + +### tan +```cpp +__device__ double tan(double x); + +``` +**Description:** Supported + + +### tanh +```cpp +__device__ double tanh(double x); + +``` +**Description:** Supported + + +### tgamma +```cpp +__device__ double tgamma(double x); + +``` +**Description:** Supported + + +### trunc +```cpp +__device__ double trunc(double x); + +``` +**Description:** Supported + + +### y0 +```cpp +__device__ double y0(double x); + +``` +**Description:** Supported + + +### y1 +```cpp +__device__ double y1(double y); + +``` +**Description:** Supported + + +### yn +```cpp +__device__ double yn(int n, double x); + +``` +**Description:** Supported + + +### __cosf +```cpp +__device__ float __cosf(float x); + +``` +**Description:** Supported + + +### __exp10f +```cpp +__device__ float __exp10f(float x); + +``` +**Description:** Supported + + +### __expf +```cpp +__device__ float __expf(float x); + +``` +**Description:** Supported + + +### __fadd_rd +```cpp +__device__ static float __fadd_rd(float x, float y); + +``` +**Description:** Supported + + +### __fadd_rn +```cpp +__device__ static float __fadd_rn(float x, float y); + +``` +**Description:** Supported + + +### __fadd_ru +```cpp +__device__ static float __fadd_ru(float x, float y); + +``` +**Description:** Supported + + +### __fadd_rz +```cpp +__device__ static float __fadd_rz(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rd +```cpp +__device__ static float __fdiv_rd(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rn +```cpp +__device__ static float __fdiv_rn(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_ru +```cpp +__device__ static float __fdiv_ru(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rz +```cpp +__device__ static float __fdiv_rz(float x, float y); + +``` +**Description:** Supported + + +### __fdividef +```cpp +__device__ static float __fdividef(float x, float y); + +``` +**Description:** Supported + + +### __fmaf_rd +```cpp +__device__ float __fmaf_rd(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_rn +```cpp +__device__ float __fmaf_rn(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_ru +```cpp +__device__ float __fmaf_ru(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_rz +```cpp +__device__ float __fmaf_rz(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmul_rd +```cpp +__device__ static float __fmul_rd(float x, float y); + +``` +**Description:** Supported + + +### __fmul_rn +```cpp +__device__ static float __fmul_rn(float x, float y); + +``` +**Description:** Supported + + +### __fmul_ru +```cpp +__device__ static float __fmul_ru(float x, float y); + +``` +**Description:** Supported + + +### __fmul_rz +```cpp +__device__ static float __fmul_rz(float x, float y); + +``` +**Description:** Supported + + +### __frcp_rd +```cpp +__device__ float __frcp_rd(float x); + +``` +**Description:** Supported + + +### __frcp_rn +```cpp +__device__ float __frcp_rn(float x); + +``` +**Description:** Supported + + +### __frcp_ru +```cpp +__device__ float __frcp_ru(float x); + +``` +**Description:** Supported + + +### __frcp_rz +```cpp +__device__ float __frcp_rz(float x); + +``` +**Description:** Supported + + +### __frsqrt_rn +```cpp +__device__ float __frsqrt_rn(float x); + +``` +**Description:** Supported + + +### __fsqrt_rd +```cpp +__device__ float __fsqrt_rd(float x); + +``` +**Description:** Supported + + +### __fsqrt_rn +```cpp +__device__ float __fsqrt_rn(float x); + +``` +**Description:** Supported + + +### __fsqrt_ru +```cpp +__device__ float __fsqrt_ru(float x); + +``` +**Description:** Supported + + +### __fsqrt_rz +```cpp +__device__ float __fsqrt_rz(float x); + +``` +**Description:** Supported + + +### __fsub_rd +```cpp +__device__ static float __fsub_rd(float x, float y); + +``` +**Description:** Supported + + +### __fsub_rn +```cpp +__device__ static float __fsub_rn(float x, float y); + +``` +**Description:** Supported + + +### __fsub_ru +```cpp +__device__ static float __fsub_ru(float x, float y); + +``` +**Description:** Supported + + +### __log10f +```cpp +__device__ float __log10f(float x); + +``` +**Description:** Supported + + +### __log2f +```cpp +__device__ float __log2f(float x); + +``` +**Description:** Supported + + +### __logf +```cpp +__device__ float __logf(float x); + +``` +**Description:** Supported + + +### __powf +```cpp +__device__ float __powf(float base, float exponent); + +``` +**Description:** Supported + + +### __saturatef +```cpp +__device__ static float __saturatef(float x); + +``` +**Description:** Supported + + +### __sincosf +```cpp +__device__ void __sincosf(float x, float *s, float *c); + +``` +**Description:** Supported + + +### __sinf +```cpp +__device__ float __sinf(float x); + +``` +**Description:** Supported + + +### __tanf +```cpp +__device__ float __tanf(float x); + +``` +**Description:** Supported + + +### __dadd_rd +```cpp +__device__ static double __dadd_rd(double x, double y); + +``` +**Description:** Supported + + +### __dadd_rn +```cpp +__device__ static double __dadd_rn(double x, double y); + +``` +**Description:** Supported + + +### __dadd_ru +```cpp +__device__ static double __dadd_ru(double x, double y); + +``` +**Description:** Supported + + +### __dadd_rz +```cpp +__device__ static double __dadd_rz(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rd +```cpp +__device__ static double __ddiv_rd(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rn +```cpp +__device__ static double __ddiv_rn(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_ru +```cpp +__device__ static double __ddiv_ru(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rz +```cpp +__device__ static double __ddiv_rz(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rd +```cpp +__device__ static double __dmul_rd(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rn +```cpp +__device__ static double __dmul_rn(double x, double y); + +``` +**Description:** Supported + + +### __dmul_ru +```cpp +__device__ static double __dmul_ru(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rz +```cpp +__device__ static double __dmul_rz(double x, double y); + +``` +**Description:** Supported + + +### __drcp_rd +```cpp +__device__ double __drcp_rd(double x); + +``` +**Description:** Supported + + +### __drcp_rn +```cpp +__device__ double __drcp_rn(double x); + +``` +**Description:** Supported + + +### __drcp_ru +```cpp +__device__ double __drcp_ru(double x); + +``` +**Description:** Supported + + +### __drcp_rz +```cpp +__device__ double __drcp_rz(double x); + +``` +**Description:** Supported + + +### __dsqrt_rd +```cpp +__device__ double __dsqrt_rd(double x); + +``` +**Description:** Supported + + +### __dsqrt_rn +```cpp +__device__ double __dsqrt_rn(double x); + +``` +**Description:** Supported + + +### __dsqrt_ru +```cpp +__device__ double __dsqrt_ru(double x); + +``` +**Description:** Supported + + +### __dsqrt_rz +```cpp +__device__ double __dsqrt_rz(double x); + +``` +**Description:** Supported + + +### __dsub_rd +```cpp +__device__ static double __dsub_rd(double x, double y); + +``` +**Description:** Supported + + +### __dsub_rn +```cpp +__device__ static double __dsub_rn(double x, double y); + +``` +**Description:** Supported + + +### __dsub_ru +```cpp +__device__ static double __dsub_ru(double x, double y); + +``` +**Description:** Supported + + +### __dsub_rz +```cpp +__device__ static double __dsub_rz(double x, double y); + +``` +**Description:** Supported + + +### __fma_rd +```cpp +__device__ double __fma_rd(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_rn +```cpp +__device__ double __fma_rn(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_ru +```cpp +__device__ double __fma_ru(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_rz +```cpp +__device__ double __fma_rz(double x, double y, double z); + +``` +**Description:** Supported + + +### __brev +```cpp +__device__ unsigned int __brev( unsigned int x); + +``` +**Description:** Supported + + +### __brevll +```cpp +__device__ unsigned long long int __brevll( unsigned long long int x); + +``` +**Description:** Supported + + +### __byte_perm +```cpp +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s); + +``` +**Description:** Supported + + +### __clz +```cpp +__device__ unsigned int __clz(int x); + +``` +**Description:** Supported + + +### __clzll +```cpp +__device__ unsigned int __clzll(long long int x); + +``` +**Description:** Supported + + +### __ffs +```cpp +__device__ unsigned int __ffs(int x); + +``` +**Description:** Supported + + +### __ffsll +```cpp +__device__ unsigned int __ffsll(long long int x); + +``` +**Description:** Supported + + +### __hadd +```cpp +__device__ static unsigned int __hadd(int x, int y); + +``` +**Description:** Supported + + +### __mul24 +```cpp +__device__ static int __mul24(int x, int y); + +``` +**Description:** Supported + + +### __mul64hi +```cpp +__device__ long long int __mul64hi(long long int x, long long int y); + +``` +**Description:** Supported + + +### __mulhi +```cpp +__device__ static int __mulhi(int x, int y); + +``` +**Description:** Supported + + +### __popc +```cpp +__device__ unsigned int __popc(unsigned int x); + +``` +**Description:** Supported + + +### __popcll +```cpp +__device__ unsigned int __popcll(unsigned long long int x); + +``` +**Description:** Supported + + +### __rhadd +```cpp +__device__ static int __rhadd(int x, int y); + +``` +**Description:** Supported + + +### __sad +```cpp +__device__ static unsigned int __sad(int x, int y, int z); + +``` +**Description:** Supported + + +### __uhadd +```cpp +__device__ static unsigned int __uhadd(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __umul24 +```cpp +__device__ static int __umul24(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __umul64hi +```cpp +__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); + +``` +**Description:** Supported + + +### __umulhi +```cpp +__device__ static unsigned int __umulhi(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __urhadd +```cpp +__device__ static unsigned int __urhadd(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __usad +```cpp +__device__ static unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + +``` +**Description:** Supported + + +### __double2float_rd +```cpp +__device__ float __double2float_rd(double x); + +``` +**Description:** Supported + + +### __double2float_rn +```cpp +__device__ float __double2float_rn(double x); + +``` +**Description:** Supported + + +### __double2float_ru +```cpp +__device__ float __double2float_ru(double x); + +``` +**Description:** Supported + + +### __double2float_rz +```cpp +__device__ float __double2float_rz(double x); + +``` +**Description:** Supported + + +### __double2hiint +```cpp +__device__ int __double2hiint(double x); + +``` +**Description:** Supported + + +### __double2int_rd +```cpp +__device__ int __double2int_rd(double x); + +``` +**Description:** Supported + + +### __double2int_rn +```cpp +__device__ int __double2int_rn(double x); + +``` +**Description:** Supported + + +### __double2int_ru +```cpp +__device__ int __double2int_ru(double x); + +``` +**Description:** Supported + + +### __double2int_rz +```cpp +__device__ int __double2int_rz(double x); + +``` +**Description:** Supported + + +### __double2ll_rd +```cpp +__device__ long long int __double2ll_rd(double x); + +``` +**Description:** Supported + + +### __double2ll_rn +```cpp +__device__ long long int __double2ll_rn(double x); + +``` +**Description:** Supported + + +### __double2ll_ru +```cpp +__device__ long long int __double2ll_ru(double x); + +``` +**Description:** Supported + + +### __double2ll_rz +```cpp +__device__ long long int __double2ll_rz(double x); + +``` +**Description:** Supported + + +### __double2loint +```cpp +__device__ int __double2loint(double x); + +``` +**Description:** Supported + + +### __double2uint_rd +```cpp +__device__ unsigned int __double2uint_rd(double x); + +``` +**Description:** Supported + + +### __double2uint_rn +```cpp +__device__ unsigned int __double2uint_rn(double x); + +``` +**Description:** Supported + + +### __double2uint_ru +```cpp +__device__ unsigned int __double2uint_ru(double x); + +``` +**Description:** Supported + + +### __double2uint_rz +```cpp +__device__ unsigned int __double2uint_rz(double x); + +``` +**Description:** Supported + + +### __double2ull_rd +```cpp +__device__ unsigned long long int __double2ull_rd(double x); + +``` +**Description:** Supported + + +### __double2ull_rn +```cpp +__device__ unsigned long long int __double2ull_rn(double x); + +``` +**Description:** Supported + + +### __double2ull_ru +```cpp +__device__ unsigned long long int __double2ull_ru(double x); + +``` +**Description:** Supported + + +### __double2ull_rz +```cpp +__device__ unsigned long long int __double2ull_rz(double x); + +``` +**Description:** Supported + + +### __double_as_longlong +```cpp +__device__ long long int __double_as_longlong(double x); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ unsigned short __float2half_rn(float x); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(unsigned short); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ __half __float2half_rn(float x); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(__half); + +``` +**Description:** Supported + + +### __float2int_rd +```cpp +__device__ int __float2int_rd(float x); + +``` +**Description:** Supported + + +### __float2int_rn +```cpp +__device__ int __float2int_rn(float x); + +``` +**Description:** Supported + + +### __float2int_ru +```cpp +__device__ int __float2int_ru(float x); + +``` +**Description:** Supported + + +### __float2int_rz +```cpp +__device__ int __float2int_rz(float x); + +``` +**Description:** Supported + + +### __float2ll_rd +```cpp +__device__ long long int __float2ll_rd(float x); + +``` +**Description:** Supported + + +### __float2ll_rn +```cpp +__device__ long long int __float2ll_rn(float x); + +``` +**Description:** Supported + + +### __float2ll_ru +```cpp +__device__ long long int __float2ll_ru(float x); + +``` +**Description:** Supported + + +### __float2ll_rz +```cpp +__device__ long long int __float2ll_rz(float x); + +``` +**Description:** Supported + + +### __float2uint_rd +```cpp +__device__ unsigned int __float2uint_rd(float x); + +``` +**Description:** Supported + + +### __float2uint_rn +```cpp +__device__ unsigned int __float2uint_rn(float x); + +``` +**Description:** Supported + + +### __float2uint_ru +```cpp +__device__ unsigned int __float2uint_ru(float x); + +``` +**Description:** Supported + + +### __float2uint_rz +```cpp +__device__ unsigned int __float2uint_rz(float x); + +``` +**Description:** Supported + + +### __float2ull_rd +```cpp +__device__ unsigned long long int __float2ull_rd(float x); + +``` +**Description:** Supported + + +### __float2ull_rn +```cpp +__device__ unsigned long long int __float2ull_rn(float x); + +``` +**Description:** Supported + + +### __float2ull_ru +```cpp +__device__ unsigned long long int __float2ull_ru(float x); + +``` +**Description:** Supported + + +### __float2ull_rz +```cpp +__device__ unsigned long long int __float2ull_rz(float x); + +``` +**Description:** Supported + + +### __float_as_int +```cpp +__device__ int __float_as_int(float x); + +``` +**Description:** Supported + + +### __float_as_uint +```cpp +__device__ unsigned int __float_as_uint(float x); + +``` +**Description:** Supported + + +### __hiloint2double +```cpp +__device__ double __hiloint2double(int hi, int lo); + +``` +**Description:** Supported + + +### __int2double_rn +```cpp +__device__ double __int2double_rn(int x); + +``` +**Description:** Supported + + +### __int2float_rd +```cpp +__device__ float __int2float_rd(int x); + +``` +**Description:** Supported + + +### __int2float_rn +```cpp +__device__ float __int2float_rn(int x); + +``` +**Description:** Supported + + +### __int2float_ru +```cpp +__device__ float __int2float_ru(int x); + +``` +**Description:** Supported + + +### __int2float_rz +```cpp +__device__ float __int2float_rz(int x); + +``` +**Description:** Supported + + +### __int_as_float +```cpp +__device__ float __int_as_float(int x); + +``` +**Description:** Supported + + +### __ll2double_rd +```cpp +__device__ double __ll2double_rd(long long int x); + +``` +**Description:** Supported + + +### __ll2double_rn +```cpp +__device__ double __ll2double_rn(long long int x); + +``` +**Description:** Supported + + +### __ll2double_ru +```cpp +__device__ double __ll2double_ru(long long int x); + +``` +**Description:** Supported + + +### __ll2double_rz +```cpp +__device__ double __ll2double_rz(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rd +```cpp +__device__ float __ll2float_rd(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rn +```cpp +__device__ float __ll2float_rn(long long int x); + +``` +**Description:** Supported + + +### __ll2float_ru +```cpp +__device__ float __ll2float_ru(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rz +```cpp +__device__ float __ll2float_rz(long long int x); + +``` +**Description:** Supported + + +### __longlong_as_double +```cpp +__device__ double __longlong_as_double(long long int x); + +``` +**Description:** Supported + + +### __uint2double_rn +```cpp +__device__ double __uint2double_rn(int x); + +``` +**Description:** Supported + + +### __uint2float_rd +```cpp +__device__ float __uint2float_rd(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_rn +```cpp +__device__ float __uint2float_rn(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_ru +```cpp +__device__ float __uint2float_ru(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_rz +```cpp +__device__ float __uint2float_rz(unsigned int x); + +``` +**Description:** Supported + + +### __uint_as_float +```cpp +__device__ float __uint_as_float(unsigned int x); + +``` +**Description:** Supported + + +### __ull2double_rd +```cpp +__device__ double __ull2double_rd(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_rn +```cpp +__device__ double __ull2double_rn(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_ru +```cpp +__device__ double __ull2double_ru(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_rz +```cpp +__device__ double __ull2double_rz(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rd +```cpp +__device__ float __ull2float_rd(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rn +```cpp +__device__ float __ull2float_rn(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_ru +```cpp +__device__ float __ull2float_ru(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rz +```cpp +__device__ float __ull2float_rz(unsigned long long int x); + +``` +**Description:** Supported + + +### __hadd +```cpp +__device__ static __half __hadd(const __half a, const __half b); + +``` +**Description:** Supported + + +### __hadd_sat +```cpp +__device__ static __half __hadd_sat(__half a, __half b); + +``` +**Description:** Supported + + +### __hfma +```cpp +__device__ static __half __hfma(__half a, __half b, __half c); + +``` +**Description:** Supported + + +### __hfma_sat +```cpp +__device__ static __half __hfma_sat(__half a, __half b, __half c); + +``` +**Description:** Supported + + +### __hmul +```cpp +__device__ static __half __hmul(__half a, __half b); + +``` +**Description:** Supported + + +### __hmul_sat +```cpp +__device__ static __half __hmul_sat(__half a, __half b); + +``` +**Description:** Supported + + +### __hneg +```cpp +__device__ static __half __hneg(__half a); + +``` +**Description:** Supported + + +### __hsub +```cpp +__device__ static __half __hsub(__half a, __half b); + +``` +**Description:** Supported + + +### __hsub_sat +```cpp +__device__ static __half __hsub_sat(__half a, __half b); + +``` +**Description:** Supported + + +### hdiv +```cpp +__device__ static __half hdiv(__half a, __half b); + +``` +**Description:** Supported + + +### __hadd2 +```cpp +__device__ static __half2 __hadd2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hadd2_sat +```cpp +__device__ static __half2 __hadd2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hfma2 +```cpp +__device__ static __half2 __hfma2(__half2 a, __half2 b, __half2 c); + +``` +**Description:** Supported + + +### __hfma2_sat +```cpp +__device__ static __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c); + +``` +**Description:** Supported + + +### __hmul2 +```cpp +__device__ static __half2 __hmul2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hmul2_sat +```cpp +__device__ static __half2 __hmul2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hsub2 +```cpp +__device__ static __half2 __hsub2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hneg2 +```cpp +__device__ static __half2 __hneg2(__half2 a); + +``` +**Description:** Supported + + +### __hsub2_sat +```cpp +__device__ static __half2 __hsub2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### h2div +```cpp +__device__ static __half2 h2div(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __heq +```cpp +__device__ bool __heq(__half a, __half b); + +``` +**Description:** Supported + + +### __hge +```cpp +__device__ bool __hge(__half a, __half b); + +``` +**Description:** Supported + + +### __hgt +```cpp +__device__ bool __hgt(__half a, __half b); + +``` +**Description:** Supported + + +### __hisinf +```cpp +__device__ bool __hisinf(__half a); + +``` +**Description:** Supported + + +### __hisnan +```cpp +__device__ bool __hisnan(__half a); + +``` +**Description:** Supported + + +### __hle +```cpp +__device__ bool __hle(__half a, __half b); + +``` +**Description:** Supported + + +### __hlt +```cpp +__device__ bool __hlt(__half a, __half b); + +``` +**Description:** Supported + + +### __hne +```cpp +__device__ bool __hne(__half a, __half b); + +``` +**Description:** Supported + + +### __hbeq2 +```cpp +__device__ bool __hbeq2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbge2 +```cpp +__device__ bool __hbge2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbgt2 +```cpp +__device__ bool __hbgt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hble2 +```cpp +__device__ bool __hble2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hblt2 +```cpp +__device__ bool __hblt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbne2 +```cpp +__device__ bool __hbne2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __heq2 +```cpp +__device__ __half2 __heq2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hge2 +```cpp +__device__ __half2 __hge2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hgt2 +```cpp +__device__ __half2 __hgt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hisnan2 +```cpp +__device__ __half2 __hisnan2(__half2 a); + +``` +**Description:** Supported + + +### __hle2 +```cpp +__device__ __half2 __hle2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hlt2 +```cpp +__device__ __half2 __hlt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hne2 +```cpp +__device__ __half2 __hne2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### hceil +```cpp +__device__ static __half hceil(const __half h); + +``` +**Description:** Supported + + +### hcos +```cpp +__device__ static __half hcos(const __half h); + +``` +**Description:** Supported + + +### hexp +```cpp +__device__ static __half hexp(const __half h); + +``` +**Description:** Supported + + +### hexp10 +```cpp +__device__ static __half hexp10(const __half h); + +``` +**Description:** Supported + + +### hexp2 +```cpp +__device__ static __half hexp2(const __half h); + +``` +**Description:** Supported + + +### hfloor +```cpp +__device__ static __half hfloor(const __half h); + +``` +**Description:** Supported + + +### hlog +```cpp +__device__ static __half hlog(const __half h); + +``` +**Description:** Supported + + +### hlog10 +```cpp +__device__ static __half hlog10(const __half h); + +``` +**Description:** Supported + + +### hlog2 +```cpp +__device__ static __half hlog2(const __half h); + +``` +**Description:** Supported + + +### hrcp +```cpp +//__device__ static __half hrcp(const __half h); + +``` +**Description:** **NOT Supported** + + +### hrint +```cpp +__device__ static __half hrint(const __half h); + +``` +**Description:** Supported + + +### hsin +```cpp +__device__ static __half hsin(const __half h); + +``` +**Description:** Supported + + +### hsqrt +```cpp +__device__ static __half hsqrt(const __half a); + +``` +**Description:** Supported + + +### htrunc +```cpp +__device__ static __half htrunc(const __half a); + +``` +**Description:** Supported + + +### h2ceil +```cpp +__device__ static __half2 h2ceil(const __half2 h); + +``` +**Description:** Supported + + +### h2exp +```cpp +__device__ static __half2 h2exp(const __half2 h); + +``` +**Description:** Supported + + +### h2exp10 +```cpp +__device__ static __half2 h2exp10(const __half2 h); + +``` +**Description:** Supported + + +### h2exp2 +```cpp +__device__ static __half2 h2exp2(const __half2 h); + +``` +**Description:** Supported + + +### h2floor +```cpp +__device__ static __half2 h2floor(const __half2 h); + +``` +**Description:** Supported + + +### h2log +```cpp +__device__ static __half2 h2log(const __half2 h); + +``` +**Description:** Supported + + +### h2log10 +```cpp +__device__ static __half2 h2log10(const __half2 h); + +``` +**Description:** Supported + + +### h2log2 +```cpp +__device__ static __half2 h2log2(const __half2 h); + +``` +**Description:** Supported + + +### h2rcp +```cpp +__device__ static __half2 h2rcp(const __half2 h); + +``` +**Description:** Supported + + +### h2rsqrt +```cpp +__device__ static __half2 h2rsqrt(const __half2 h); + +``` +**Description:** Supported + + +### h2sin +```cpp +__device__ static __half2 h2sin(const __half2 h); + +``` +**Description:** Supported + + +### h2sqrt +```cpp +__device__ static __half2 h2sqrt(const __half2 h); + +``` +**Description:** Supported + + +### __float22half2_rn +```cpp +__device__ __half2 __float22half2_rn(const float2 a); + +``` +**Description:** Supported + + +### __float2half +```cpp +__device__ __half __float2half(const float a); + +``` +**Description:** Supported + + +### __float2half2_rn +```cpp +__device__ __half2 __float2half2_rn(const float a); + +``` +**Description:** Supported + + +### __float2half_rd +```cpp +__device__ __half __float2half_rd(const float a); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ __half __float2half_rn(const float a); + +``` +**Description:** Supported + + +### __float2half_ru +```cpp +__device__ __half __float2half_ru(const float a); + +``` +**Description:** Supported + + +### __float2half_rz +```cpp +__device__ __half __float2half_rz(const float a); + +``` +**Description:** Supported + + +### __floats2half2_rn +```cpp +__device__ __half2 __floats2half2_rn(const float a, const float b); + +``` +**Description:** Supported + + +### __half22float2 +```cpp +__device__ float2 __half22float2(const __half2 a); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(const __half a); + +``` +**Description:** Supported + + +### half2half2 +```cpp +__device__ __half2 half2half2(const __half a); + +``` +**Description:** Supported + + +### __half2int_rd +```cpp +__device__ int __half2int_rd(__half h); + +``` +**Description:** Supported + + +### __half2int_rn +```cpp +__device__ int __half2int_rn(__half h); + +``` +**Description:** Supported + + +### __half2int_ru +```cpp +__device__ int __half2int_ru(__half h); + +``` +**Description:** Supported + + +### __half2int_rz +```cpp +__device__ int __half2int_rz(__half h); + +``` +**Description:** Supported + + +### __half2ll_rd +```cpp +__device__ long long int __half2ll_rd(__half h); + +``` +**Description:** Supported + + +### __half2ll_rn +```cpp +__device__ long long int __half2ll_rn(__half h); + +``` +**Description:** Supported + + +### __half2ll_ru +```cpp +__device__ long long int __half2ll_ru(__half h); + +``` +**Description:** Supported + + +### __half2ll_rz +```cpp +__device__ long long int __half2ll_rz(__half h); + +``` +**Description:** Supported + + +### __half2short_rd +```cpp +__device__ short __half2short_rd(__half h); + +``` +**Description:** Supported + + +### __half2short_rn +```cpp +__device__ short __half2short_rn(__half h); + +``` +**Description:** Supported + + +### __half2short_ru +```cpp +__device__ short __half2short_ru(__half h); + +``` +**Description:** Supported + + +### __half2short_rz +```cpp +__device__ short __half2short_rz(__half h); + +``` +**Description:** Supported + + +### __half2uint_rd +```cpp +__device__ unsigned int __half2uint_rd(__half h); + +``` +**Description:** Supported + + +### __half2uint_rn +```cpp +__device__ unsigned int __half2uint_rn(__half h); + +``` +**Description:** Supported + + +### __half2uint_ru +```cpp +__device__ unsigned int __half2uint_ru(__half h); + +``` +**Description:** Supported + + +### __half2uint_rz +```cpp +__device__ unsigned int __half2uint_rz(__half h); + +``` +**Description:** Supported + + +### __half2ull_rd +```cpp +__device__ unsigned long long int __half2ull_rd(__half h); + +``` +**Description:** Supported + + +### __half2ull_rn +```cpp +__device__ unsigned long long int __half2ull_rn(__half h); + +``` +**Description:** Supported + + +### __half2ull_ru +```cpp +__device__ unsigned long long int __half2ull_ru(__half h); + +``` +**Description:** Supported + + +### __half2ull_rz +```cpp +__device__ unsigned long long int __half2ull_rz(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rd +```cpp +__device__ unsigned short int __half2ushort_rd(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rn +```cpp +__device__ unsigned short int __half2ushort_rn(__half h); + +``` +**Description:** Supported + + +### __half2ushort_ru +```cpp +__device__ unsigned short int __half2ushort_ru(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rz +```cpp +__device__ unsigned short int __half2ushort_rz(__half h); + +``` +**Description:** Supported + + +### __half_as_short +```cpp +__device__ short int __half_as_short(const __half h); + +``` +**Description:** Supported + + +### __half_as_ushort +```cpp +__device__ unsigned short int __half_as_ushort(const __half h); + +``` +**Description:** Supported + + +### __halves2half2 +```cpp +__device__ __half2 __halves2half2(const __half a, const __half b); + +``` +**Description:** Supported + + +### __high2float +```cpp +__device__ float __high2float(const __half2 a); + +``` +**Description:** Supported + + +### __high2half +```cpp +__device__ __half __high2half(const __half2 a); + +``` +**Description:** Supported + + +### __high2half2 +```cpp +__device__ __half2 __high2half2(const __half2 a); + +``` +**Description:** Supported + + +### __highs2half2 +```cpp +__device__ __half2 __highs2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __int2half_rd +```cpp +__device__ __half __int2half_rd(int i); + +``` +**Description:** Supported + + +### __int2half_rn +```cpp +__device__ __half __int2half_rn(int i); + +``` +**Description:** Supported + + +### __int2half_ru +```cpp +__device__ __half __int2half_ru(int i); + +``` +**Description:** Supported + + +### __int2half_rz +```cpp +__device__ __half __int2half_rz(int i); + +``` +**Description:** Supported + + +### __ll2half_rd +```cpp +__device__ __half __ll2half_rd(long long int i); + +``` +**Description:** Supported + + +### __ll2half_rn +```cpp +__device__ __half __ll2half_rn(long long int i); + +``` +**Description:** Supported + + +### __ll2half_ru +```cpp +__device__ __half __ll2half_ru(long long int i); + +``` +**Description:** Supported + + +### __ll2half_rz +```cpp +__device__ __half __ll2half_rz(long long int i); + +``` +**Description:** Supported + + +### __low2float +```cpp +__device__ float __low2float(const __half2 a); + +``` +**Description:** Supported + + +### __low2half +```cpp +__device__ __half __low2half(const __half2 a); + +``` +**Description:** Supported + + +### __low2half2 +```cpp +__device__ __half2 __low2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __low2half2 +```cpp +__device__ __half2 __low2half2(const __half2 a); + +``` +**Description:** Supported + + +### __lowhigh2highlow +```cpp +__device__ __half2 __lowhigh2highlow(const __half2 a); + +``` +**Description:** Supported + + +### __lows2half2 +```cpp +__device__ __half2 __lows2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __short2half_rd +```cpp +__device__ __half __short2half_rd(short int i); + +``` +**Description:** Supported + + +### __short2half_rn +```cpp +__device__ __half __short2half_rn(short int i); + +``` +**Description:** Supported + + +### __short2half_ru +```cpp +__device__ __half __short2half_ru(short int i); + +``` +**Description:** Supported + + +### __short2half_rz +```cpp +__device__ __half __short2half_rz(short int i); + +``` +**Description:** Supported + + +### __uint2half_rd +```cpp +__device__ __half __uint2half_rd(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_rn +```cpp +__device__ __half __uint2half_rn(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_ru +```cpp +__device__ __half __uint2half_ru(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_rz +```cpp +__device__ __half __uint2half_rz(unsigned int i); + +``` +**Description:** Supported + + +### __ull2half_rd +```cpp +__device__ __half __ull2half_rd(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_rn +```cpp +__device__ __half __ull2half_rn(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_ru +```cpp +__device__ __half __ull2half_ru(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_rz +```cpp +__device__ __half __ull2half_rz(unsigned long long int i); + +``` +**Description:** Supported + + +### __ushort2half_rd +```cpp +__device__ __half __ushort2half_rd(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_rn +```cpp +__device__ __half __ushort2half_rn(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_ru +```cpp +__device__ __half __ushort2half_ru(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_rz +```cpp +__device__ __half __ushort2half_rz(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort_as_half +```cpp +__device__ __half __ushort_as_half(const unsigned short int i); + +``` +**Description:** Supported + + diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md new file mode 100644 index 0000000000..abb31d80e8 --- /dev/null +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -0,0 +1,221 @@ +# HIP Bugs + + +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**`](#errors-related-to-undefined-reference-to-__hclaunchkernel____grid_launch_parm) +- [What is the current limitation of HIP Generic Grid Launch method?](#what-is-the-current-limitation-of-hip-generic-grid-launch-method) +- [Errors related to `no matching constructor`](#errors-related-to-no-matching-constructor) +- [HIP is more restrictive in enforcing restrictions](#hip-is-more-restrictive-in-enforcing-restrictions) + + + +### Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**` + +Some common code practices may lead to hipcc generating a error with the form : +``` +undefined reference to `__hcLaunchKernel__ZN15vecAddNamespace6vecAddIidEEv16grid_launch_parmPT0_S3_S3_T_ +``` +Or: +``` +error: weak declaration cannot have internal linkage +``` + +Suggested workarounds: +- Avoid use of static with kernel definition: +```c++ +static __global__ MyKernel +``` + +- Avoid defining kernels in anonymous namespace : +```c++ +namespace { + __global__ MyKernel +} +``` + +### Can't find kernels inside dynamic linked library + +HCC requires use of the "-Bdynamic" flag when creating a dynamic library which contains kernels. The dynamic flag causes the symbols to be created with a signature which allows HCC to discover and load the kernels in the dynamic library. This flag is often not set by default and must be added to the link step of the library. If not done, HCC will be unable to find the kernels defined in the library, and will emit a message such as: + +``` +HSADevice::CreateKernel(): Unable to create kernel" +``` + +To correct, add the following flag to hcc or hipcc: +``` +$ hipcc -Wl,-Bsymbolic ... +``` + + +### What is the current limitation of HIP Generic Grid Launch method? +1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); +2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. + + +### Errors related to `no matching constructor` + +The symptom is the compiler would complain about errors like `no matching constructor` for classes/structs passed as arguments into a GPU kernel. Often, this is caused by a design limitation in HCC where array-typed member variables inside a class/struct can’t be correctly passed into GPU kernels. To mitigate this issue, a custom serializer/deserializer pair is provided. + +For example, `Foo` in the code snippets below contains an array-typed member variable `table`, which would fail the compiler if used as a kernel argument. + +``` +struct Foo { + float _data; + // table is an array, which makes foo + int table[3]; +}; +``` + +A workaround is to provide a custom serializer on host side which appends the contents of the array as kernel arguments, and a custome deserializaer on the device path to reconstruct the array inside the GPU kernels. +The deserializer can not be a function template, and should have scalar-typed parameters of the number equals to the length of the array-typed member variable. For example: + +``` + +struct Foo { + float _data; + int _table[3]; + + +#ifdef __HCC__ + // user-provided CPU serializer + // Append the contents of the array member as kernel arguments + __attribute__((annotate(“serialize”))) + void __cxxamp_serialize(Kalmar::Serialize &s) const { + s.Append(sizeof(float), &_data); + for (int i = 0; i < 3; ++i) + s.Append(sizeof(int), &_table[i]); + } + + + // user-provided GPU deserializer + // table has 3 int elements, so deserializer must have 3 int parameters. + __attribute__((annotate(“user_deserialize”))) + Foo(float d, int x0, int x1, int x2) [[cpu]][[hc]] { + _data = d; + _table[0] = x0; + _table[1] = x1; + _table[2] = x2; + } + +#endif +}; +``` + + +Rather than create serializer functions, another workaround is to pass the member fields from the structure as simple data types. +Note a class or struct can contain only one "user_deserialize" constructor. +For types which contain arrays which are based on template parameter, you can use partial template instantiation to implement one constructor per specialization. +However, an easier approach may be to create one user_deserializer which processes the maximum supported dimension. +This will take more memory in the structure and also require additional kernel arguments, but this may have little performance impact and the conversion is easier than partial template specialization. An example: + +``` +#define MAX_Dim 4 +template struct MyArray { + + T* dataPtr_; + //int size_[Dim]; // Original code with template-sized Dims + int size_[MAX_dim]; // Workaround code - allocate an array big enough for all dims so one serializer works. + + +... + +#ifdef __HCC__ + __attribute__((annotate("serialize"))) + void __cxxamp_serialize(Kalmar::Serialize &s) const { + s.Append(sizeof(float), &_dataPtr); + for (int i=0; i +#include + +struct aye { bool a[1]; }; +struct nay { bool a[2]; }; + +// Dual restriction is necessary in HIP if the detector is to work for +// __device__ contexts as well as __host__ ones. NVCC is less strict. +template +__host__ __device__ +const T& cref_t(); + +template +struct Has_call_operator { + // Dual restriction is necessary in HIP if the detector is to work for + // __device__ contexts as well as __host__ ones. NVCC is less strict. + template + __host__ __device__ + static + aye test( + C const *, + typename std::enable_if< + (sizeof(cref_t().operator()()) > 0)>::type* = nullptr); + static + nay test(...); + + enum { value = sizeof(test(static_cast(0))) == sizeof(aye) }; +}; + +template::value> +struct Wrapper { + template + V f() const { return T{1}; } +}; + + +template +struct Wrapper { + template + V f() const { return T{10}; } +}; + +// This specialisation will yield a compile-time error, if selected. +template +struct Wrapper {}; + +template +struct Functor; + +template<> struct Functor { + __device__ + float operator()() const { return 42.0f; } +}; + +__device__ +void this_will_not_compile_if_detector_is_not_marked_device() +{ + float f = Wrapper>().f(); +} + +__host__ +void this_will_not_compile_if_detector_is_marked_device_only() +{ + float f = Wrapper>().f(); +} +``` +[1]: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Member_Detector diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 70ad94ba43..e316d449ef 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -4,13 +4,13 @@ - [What APIs and features does HIP support?](#what-apis-and-features-does-hip-support) - [What is not supported?](#what-is-not-supported) - * [Run-time features](#run-time-features) + * [Runtime/Driver API features](#runtimedriver-api-features) * [Kernel language features](#kernel-language-features) - [Is HIP a drop-in replacement for CUDA?](#is-hip-a-drop-in-replacement-for-cuda) - [What specific version of CUDA does HIP support?](#what-specific-version-of-cuda-does-hip-support) - [What libraries does HIP support?](#what-libraries-does-hip-support) - [How does HIP compare with OpenCL?](#how-does-hip-compare-with-opencl) -- [How does porting CUDA to HIP compare to porting CUDA to OpenCL?] +- [How does porting CUDA to HIP compare to porting CUDA to OpenCL?](#how-does-porting-cuda-to-hip-compare-to-porting-cuda-to-opencl) - [What hardware does HIP support?](#what-hardware-does-hip-support) - [Does Hipify automatically convert all source code?](#does-hipify-automatically-convert-all-source-code) - [What is NVCC?](#what-is-nvcc) @@ -23,9 +23,11 @@ - [On HCC, can I link HIP code with host code compiled with another compiler such as gcc, icc, or clang ?](#on-hcc-can-i-link-hip-code-with-host-code-compiled-with-another-compiler-such-as-gcc-icc-or-clang-) - [HIP detected my platform (hcc vs nvcc) incorrectly - what should I do?](#hip-detected-my-platform-hcc-vs-nvcc-incorrectly---what-should-i-do) - [Can I install both CUDA SDK and HCC on same machine?](#can-i-install-both-cuda-sdk-and-hcc-on-same-machine) +- [On CUDA, can I mix CUDA code with HIP code?](#on-cuda-can-i-mix-cuda-code-with-hip-code) +- [On HCC, can I use HC functionality with HIP?](#on-hcc-can-i-use-hc-functionality-with-hip) - [How do I trace HIP application flow?](#how-do-i-trace-hip-application-flow) - * [Using CodeXL markers for HIP Functions](#using-codexl-markers-for-hip-functions) - * [Using HIP_TRACE_API](#using-hip_trace_api) +- [What if HIP generates error of "symbol multiply defined!" only on AMD machine?](#what-if-hip-generates-error-of-symbol-multiply-defined-only-on-amd-machine) +- [How do I disable HIP Generic Grid Launch option?](#how-do-i-disable-hip-generic-grid-launch-option) @@ -50,10 +52,9 @@ At a high-level, the following features are not supported: - Textures - Dynamic parallelism (CUDA 5.0) - Managed memory (CUDA 6.5) -- Graphics interoperation with OpenGL or Direct3D +- Graphics interoperability with OpenGL or Direct3D - CUDA Driver API (Under Development) - CUDA IPC Functions (Under Development) - - CUDA array, mipmappedArray and pitched memory - MemcpyToSymbol functions - Queue priority controls @@ -76,13 +77,13 @@ See the [API Support Table](CUDA_Runtime_API_functions_supported_by_HIP.md) for ### Is HIP a drop-in replacement for CUDA? -No. HIP provides porting tools which do most of the work do convert CUDA code into portable C++ code that uses the HIP APIs. +No. HIP provides porting tools which do most of the work to convert CUDA code into portable C++ code that uses the HIP APIs. Most developers will port their code from CUDA to HIP and then maintain the HIP version. HIP code provides the same performance as native CUDA code, plus the benefits of running on AMD platforms. ### What specific version of CUDA does HIP support? -HIP APIs and features do not map to a specific CUDA version. HIP provides a strong subset of functionality provided in CUDA, and the hipify tools can -scan code to identify any unsupported CUDA functions - this is very useful for identifying the specific features required by a given application. +HIP APIs and features do not map to a specific CUDA version. HIP provides a strong subset of functionality provided in CUDA, and the hipify tools can +scan code to identify any unsupported CUDA functions - this is useful for identifying the specific features required by a given application. However, we can provide a rough summary of the features included in each CUDA SDK and the support level in HIP: @@ -106,8 +107,8 @@ However, we can provide a rough summary of the features included in each CUDA SD - TBD. ### What libraries does HIP support? -HIP includes growing support for the 4 key math libraries using hcBlas, hcFft, hcrng, and hcsparse). -These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaces with other HCC code. Developers should use conditional compliation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. +HIP includes growing support for the 4 key math libraries using hcBlas, hcFft, hcrng and hcsparse. +These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaced with other HCC applications. Developers should use conditional compilation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. - [hcblas](https://bitbucket.org/multicoreware/hcblas) - [hcfft](https://bitbucket.org/multicoreware/hcfft) @@ -131,47 +132,47 @@ HIP offers several benefits over OpenCL: ### How does porting CUDA to HIP compare to porting CUDA to OpenCL? Both HIP and CUDA are dialects of C++, and thus porting between them is relatively straightforward. Both dialects support templates, classes, lambdas, and other C++ constructs. -As one example, the hipify tool was originally a perl script that used simple text conversions from CUDA to HIP. -HIP and CUDA provide similar math library calls as well. In summary, the HIP philospohy was to make the HIP language close enough to CUDA that the porting effort is relatively simple. +As one example, the hipify tool was originally a Perl script that used simple text conversions from CUDA to HIP. +HIP and CUDA provide similar math library calls as well. In summary, the HIP philosophy was to make the HIP language close enough to CUDA that the porting effort is relatively simple. This reduces the potential for error, and also makes it easy to automate the translation. HIP's goal is to quickly get the ported program running on both platforms with little manual intervention, so that the programmer can focus on performance optimizations. There have been several tools that have attempted to convert CUDA into OpenCL, such as CU2CL. OpenCL is a C99-based kernel language (rather than C++) and also does not support single-source compilation. -As a result, the OpenCL syntax is quite different than CUDA, and the porting tools have to perform some heroic transformations to bridge this gap. +As a result, the OpenCL syntax is different from CUDA, and the porting tools have to perform some heroic transformations to bridge this gap. The tools also struggle with more complex CUDA applications, in particular those that use templates, classes, or other C++ features inside the kernel. ### What hardware does HIP support? -- For AMD platforms, HIP runs on the same hardware that the HCC "hc" mode supports. See the ROCM documentation for the list of supported platforms. -- For Nvidia platforms, HIP requires Unified Memory and should run on a device which runs the CUDA SDK 6.0 or newer. We have tested the Nvidia Titan and K40. +- For AMD platforms, HIP runs on the same hardware that the HCC "hc" mode supports. See the ROCm documentation for the list of supported platforms. +- For Nvidia platforms, HIP requires Unified Memory and should run on any device supporting CUDA SDK 6.0 or newer. We have tested the Nvidia Titan and Tesla K40. ### Does Hipify automatically convert all source code? -Typically, Hipify can automatically convert almost all run-time code, and the coordinate indexing device code (i.e. threadIdx.x -> hipThreadIdx_x). +Typically, hipify can automatically convert almost all run-time code, and the coordinate indexing device code ( threadIdx.x -> hipThreadIdx_x ). Most device code needs no additional conversion, since HIP and CUDA have similar names for math and built-in functions. The hipify-clang tool will automatically modify the kernel signature as needed (automating a step that used to be done manually) Additional porting may be required to deal with architecture feature queries or with CUDA capabilities that HIP doesn't support. In general, developers should always expect to perform some platform-specific tuning and optimization. ### What is NVCC? -NVCC is Nvidia's compiler driver for compiling "CUDA C++" code into PTX or device code for Nvidia GPUs. It's a closed-source binary product that comes with CUDA SDKs. +NVCC is Nvidia's compiler driver for compiling "CUDA C++" code into PTX or device code for Nvidia GPUs. It's a closed-source binary compiler that is provided by the CUDA SDK. ### What is HCC? -HCC is AMD's compiler driver which compiles "heterogenous C++" code into HSAIL or GCN device code for AMD GPUs. It's an open-source compiler based on recent versions of CLANG/LLVM. +HCC is AMD's compiler driver which compiles "heterogeneous C++" code into HSAIL or GCN device code for AMD GPUs. It's an open-source compiler based on recent versions of CLANG/LLVM. ### Why use HIP rather than supporting CUDA directly? While HIP is a strong subset of the CUDA, it is a subset. The HIP layer allows that subset to be clearly defined and documented. -Developers who code to the HIP API can be assured there code will remain portable across Nvidia and AMD platforms. +Developers who code to the HIP API can be assured their code will remain portable across Nvidia and AMD platforms. In addition, HIP defines portable mechanisms to query architectural features, and supports a larger 64-bit wavesize which expands the return type for cross-lane functions like ballot and shuffle from 32-bit ints to 64-bit ints. ### Can I develop HIP code on an Nvidia CUDA platform? -Yes! HIP's CUDA path only exposes the APIs and functionality that work on both NVCC and HCC back-ends. -"Extra" APIs, parameters, and features which exist in CUDA but not in HCC will typically result in compile-time or run-time errors. -Developers need to use the HIP API for most accelerator code, and bracket any CUDA-specific code with appropriate ifdefs. +Yes. HIP's CUDA path only exposes the APIs and functionality that work on both NVCC and HCC back-ends. +"Extra" APIs, parameters, and features which exist in CUDA but not in HCC will typically result in compile- or run-time errors. +Developers need to use the HIP API for most accelerator code, and bracket any CUDA-specific code with preprocessor conditionals. Developers concerned about portability should of course run on both platforms, and should expect to tune for performance. In some cases CUDA has a richer set of modes for some APIs, and some C++ capabilities such as virtual functions - see the HIP @API documentation for more details. ### Can I develop HIP code on an AMD HCC platform? -Yes! HIP's HCC path only exposes the APIs and functions that work on both NVCC and HCC back ends. "Extra" APIs, parameters and features that appear in HCC but not CUDA will typically cause compile- or run-time errors. Developers must use the HIP API for most accelerator code and bracket any HCC-specific code with appropriate ifdefs. Those concerned about portability should, of course, test their code on both platforms and should tune it for performance. Typically, HCC supports a more modern set of C++11/C++14/C++17 features, so HIP developers who want portability should be careful when using advanced C++ features on the hc path. +Yes. HIP's HCC path only exposes the APIs and functions that work on both NVCC and HCC back ends. "Extra" APIs, parameters and features that appear in HCC but not CUDA will typically cause compile- or run-time errors. Developers must use the HIP API for most accelerator code and bracket any HCC-specific code with preprocessor conditionals. Those concerned about portability should, of course, test their code on both platforms and should tune it for performance. Typically, HCC supports a more modern set of C++11/C++14/C++17 features, so HIP developers who want portability should be careful when using advanced C++ features on the hc path. ### Can a HIP binary run on both AMD and Nvidia platforms? HIP is a source-portable language that can be compiled to run on either the HCC or NVCC platform. HIP tools don't create a "fat binary" that can run on either platform, however. @@ -184,9 +185,9 @@ A C++ dialect, hc is supported by the AMD HCC compiler. It provides C++ run time ### On HCC, can I link HIP code with host code compiled with another compiler such as gcc, icc, or clang ? -Yes! HIP/HCC generates the object code which conforms to the GCC ABI, and also links with libstdc++. This means you can compile host code with the compiler of your choice and link this -with GPU code compiler with HIP. Larger projects often contain a mixture of accelerator code (initially written in CUDA with nvcc) plus host code (compiled with gcc, icc, or clang). These projects -can convert the accelerator code to HIP, compile that code with hipcc, and link with object code from the preferred compiler.S +Yes. HIP/HCC generates the object code which conforms to the GCC ABI, and also links with libstdc++. This means you can compile host code with the compiler of your choice and link the generated object code +with GPU code compiled with HIP. Larger projects often contain a mixture of accelerator code (initially written in CUDA with nvcc) and host code (compiled with gcc, icc, or clang). These projects +can convert the accelerator code to HIP, compile that code with hipcc, and link with object code from their preferred compiler. @@ -196,9 +197,9 @@ HIP will set the platform to HCC if it sees that the AMD graphics driver is inst Sometimes this isn't what you want - you can force HIP to recognize the platform by setting HIP_PLATFORM to hcc (or nvcc) ``` export HIP_PLATFORM=hcc - ``` -One symptom of this problem is the message "error: 'unknown error'(11) at square.hipref.cpp:56". This can occur if you have a CUDA installation on an AMD platform, and HIP incorrectly detects the platform as nvcc. HIP may be able to compile the application using the nvcc tool-chain, but will generate this error at runtime since the platform does not have a CUDA device. The fix is to set HIP_PLATFORM=hcc and rebuild the issue. + +One symptom of this problem is the message "error: 'unknown error'(11) at square.hipref.cpp:56". This can occur if you have a CUDA installation on an AMD platform, and HIP incorrectly detects the platform as nvcc. HIP may be able to compile the application using the nvcc tool-chain, but will generate this error at runtime since the platform does not have a CUDA device. The fix is to set HIP_PLATFORM=hcc and rebuild. If you see issues related to incorrect platform detection, please file an issue with the GitHub issue tracker so we can improve HIP's platform detection logic. @@ -207,7 +208,7 @@ Yes. You can use HIP_PLATFORM to choose which path hipcc targets. This configur ### On CUDA, can I mix CUDA code with HIP code? -Yes. Most HIP data structures (hipStream_t, hipEvent_t) are typedefs to CUDA equivalents and can be intermixed. Both CUDA and HIP use integer device ids . +Yes. Most HIP data structures (hipStream_t, hipEvent_t) are typedefs to CUDA equivalents and can be intermixed. Both CUDA and HIP use integer device ids. One notable exception is that hipError_t is a new type, and cannot be used where a cudaError_t is expected. In these cases, refactor the code to remove the expectation. Alternatively, hip_runtime_api.h defines functions which convert between the error code spaces: hipErrorToCudaError @@ -218,10 +219,10 @@ If platform portability is important, use #ifdef __HIP_PLATFORM_NVCC__ to guard ### On HCC, can I use HC functionality with HIP? Yes. -The code can include hc.hpp and use HC functions inside the kernel. A typical use case is to use AMD-specific hardware features such as the permute, swizzle, or DPP operations. +The code can include hc.hpp and use HC functions inside the kernel. A typical use-case is to use AMD-specific hardware features such as the permute, swizzle, or DPP operations. The "-stdlib=libc++" must be passed to hipcc in order to compile hc.hpp. See the 'bit_extract' sample for an example. -Also these functions can be used to extract HCC acclerator and accelerator_view structures from the HIP deviceId and hipStream_t: +Also these functions can be used to extract HCC accelerator and accelerator_view structures from the HIP deviceId and hipStream_t: hipHccGetAccelerator(int deviceId, hc::accelerator *acc); hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); @@ -236,3 +237,9 @@ Unlike CUDA, in HCC, for functions defined in the header files, the keyword of " Thus, if failed to define "static" keyword, you might see a lot of "symbol multiply defined!" errors at compilation. The workaround is to explicitly add the keyword of "static" before any functions that were defined as "__forceinline__". +### How do I disable HIP Generic Grid Launch option? +Generic Grid Launch(GGL) is currently the default method for hip kernel launch. +To disable it and use the legancy grid launch method, please either change the default value of GENERIC_GRID_LAUNCH to 0 in the following to header files and rebuild HIP: +$HIP/include/hip/hcc_detail/hip_runtime_api.h +$HIP/include/hip/hcc_detail/host_defines.h +Or pass "-DGENERIC_GRID_LAUNCH=0" to hipcc at application compilation time. diff --git a/projects/hip/docs/markdown/hip_kernel_language.md b/projects/hip/docs/markdown/hip_kernel_language.md index f84868987c..3cb7b17a0c 100644 --- a/projects/hip/docs/markdown/hip_kernel_language.md +++ b/projects/hip/docs/markdown/hip_kernel_language.md @@ -44,6 +44,7 @@ - [Pragma Unroll](#pragma-unroll) - [In-Line Assembly](#in-line-assembly) - [C++ Support](#c-support) +- [Kernel Compilation](#kernel-compilation) @@ -105,7 +106,7 @@ HIP parses the `__noinline__` and `__forceinline__` keywords and converts them t ``` -// Example psuedocode introducing hipLaunchKernel: +// Example pseudo code introducing hipLaunchKernel: __global__ MyKernel(hipLaunchParm lp, float *A, float *B, float *C, size_t N) { ... @@ -680,7 +681,7 @@ The user can specify the target for which the binary can be generated. HIP/HCC d The file format for binary is `.co` which means Code Object. The following command builds the code object using `hipcc`. `hipcc --genco --target-isa=[TARGET GPU] [INPUT FILE] -o [OUTPUT FILE]` -```[TARGET GPU] = fiji/hawaii +```[TARGET GPU] = gfx803/gfx701 [INPUT FILE] = Name of the file containing kernels [OUTPUT FILE] = Name of the generated code object file``` diff --git a/projects/hip/docs/markdown/hip_performance.md b/projects/hip/docs/markdown/hip_performance.md index bd550c9255..67a2f88b58 100644 --- a/projects/hip/docs/markdown/hip_performance.md +++ b/projects/hip/docs/markdown/hip_performance.md @@ -6,18 +6,18 @@ Please note that this document lists possible ways for experimenting with HIP st #### On Small BAR Setup -There are two possible ways to transfer data from Host to Device (H2D) and Device to Host(D2H) +There are two possible ways to transfer data from host-to-device (H2D) and device-to-host(D2H) * Using Staging Buffers * Using PinInPlace #### On Large BAR Setup -There are three possible ways to transfer data from Host to Device (H2D) +There are three possible ways to transfer data from host-to-device (H2D) * Using Staging Buffers * Using PinInPlace * Direct Memcpy - And there are two possible ways to transfer data from Device to Host (D2H) + And there are two possible ways to transfer data from device-to-host (D2H) * Using Staging Buffers * Using PinInPlace diff --git a/projects/hip/docs/markdown/hip_porting_driver_api.md b/projects/hip/docs/markdown/hip_porting_driver_api.md index b0ac3ecf1d..dd3b9c3e86 100644 --- a/projects/hip/docs/markdown/hip_porting_driver_api.md +++ b/projects/hip/docs/markdown/hip_porting_driver_api.md @@ -1,151 +1,119 @@ # Porting CUDA Driver API ## Introduction to the CUDA Driver and Runtime APIs -CUDA provides a separate CUDA Driver and Runtime APIs. The two APis have significant overlap in functionality: +CUDA provides a separate CUDA Driver and Runtime APIs. The two APIs have significant overlap in functionality: - Both APIs support events, streams, memory management, memory copy, and error handling. -- Both APIs deliver similar performance. -- Driver APIs calls begin with the prefix `cu` while Runtime APIs begin with the prefix `cuda`. For example, the Driver API API contains `cuEventCreate` while the Runtime API contains `cudaEventCreate`, with similar functionality. -- The Driver API defines a different but largely overlapping error code code space than the Runtime API, and uses a different coding convention. For example, Driver API defines `CUDA_ERROR_INVALID_VALUE` while the Runtime API defines `cudaErrorInvalidValue` +- Both APIs deliver similar performance. +- Driver APIs calls begin with the prefix `cu` while Runtime APIs begin with the prefix `cuda`. For example, the Driver API API contains `cuEventCreate` while the Runtime API contains `cudaEventCreate`, with similar functionality. +- The Driver API defines a different but largely overlapping error code space than the Runtime API, and uses a different coding convention. For example, Driver API defines `CUDA_ERROR_INVALID_VALUE` while the Runtime API defines `cudaErrorInvalidValue` The Driver API offers two additional pieces of functionality not provided by the Runtime API: cuModule and cuCtx APIs. ### cuModule API -The Module section of the Driver API provides additional control over how and when accelerator - code objects are loaded. +The Module section of the Driver API provides additional control over how and when accelerator code objects are loaded. For example, the driver API allows code objects to be loaded from files or memory pointers. Symbols for kernels or global data can be extracted from the loaded code objects. -In contrast, the Runtime API automatically loads and (if necessary) compiles all of the -kernels from a executable binary when run. +In contrast, the Runtime API automatically loads and (if necessary) compiles all of the kernels from an executable binary when run. In this mode, NVCC must be used to compile kernel code so the automatic loading can function correctly. Both Driver and Runtime APIs define a function for launching kernels (called `cuLaunchKernel` or `cudaLaunchKernel`. The kernel arguments and the execution configuration (grid dimensions, group dimensions, dynamic shared memory, and stream) are passed as arguments to the launch function. -The Runtime additionally provides the `<<< >>>` syntax for launching kernels, which resembles -a special function call and is easier to use than explicit launch API (in particular with respect to -handling of kernel arguments). -However, this syntax is not standard C++ and is available only when NVCC is used to compile the host code. +The Runtime additionally provides the `<<< >>>` syntax for launching kernels, which resembles a special function call and is easier to use than explicit launch API (in particular with respect to handling of kernel arguments). +However, this syntax is not standard C++ and is available only when NVCC is used to compile the host code. -The Module features are useful in an environment which generate the code objects directly, such as a new -accelerator language front-end. Here, NVCC is not used. Instead, the environment may have a -different kernel language or different compilation flow. +The Module features are useful in an environment which generates the code objects directly, such as a new accelerator language front-end. +Here, NVCC is not used. Instead, the environment may have a different kernel language or different compilation flow. Other environments have many kernels and do not want them to be all loaded automatically. The Module functions can be used to load the generated code objects and launch kernels. -As we will see below, HIP defines a Module API which provides similar explict control over code -object managemenet. +As we will see below, HIP defines a Module API which provides similar explicit control over code object management. ### cuCtx API -The Driver API defines "Context" and "Devices" as separate entities. -Contexts contain a single device, and a device can theoretically have multiple contexts. -Each context contains a set of streams and events specific to the context. -Historically contexts also defined a unique address space for the GPU, though this may not longer be the case in Unified Memory platforms (since the CPU and all the devices in the same process share a single unified address space). -The Context APIs also provide a mechanism to switch between devices, which allowed -a single CPU thread to send commands to different GPUs. HIP as well as a recent versions -of CUDA Runtime provide other mechanisms to accomplish this feat - for example using streams or -`cudaSetDevice`. +The Driver API defines "Context" and "Devices" as separate entities. +Contexts contain a single device, and a device can theoretically have multiple contexts. +Each context contains a set of streams and events specific to the context. +Historically contexts also defined a unique address space for the GPU, though this may no longer be the case in Unified Memory platforms (since the CPU and all the devices in the same process share a single unified address space). +The Context APIs also provide a mechanism to switch between devices, which allowed a single CPU thread to send commands to different GPUs. +HIP as well as a recent versions of CUDA Runtime provide other mechanisms to accomplish this feat - for example using streams or `cudaSetDevice`. -The CUDA Runtime API unifies the Context API with the Device API. This simplifies the APIs -and has little loss of functionality since each Context can contain a single device, -and the benefits of multiple contexts has been replaced with other interfaces. HIP provides -a context API to facilitate easy porting from existing Driver codes. -In HIP, the Ctx functions largely provide an alternate syntax for changing the active device. +The CUDA Runtime API unifies the Context API with the Device API. This simplifies the APIs and has little loss of functionality since each Context can contain a single device, and the benefits of multiple contexts has been replaced with other interfaces. +HIP provides a context API to facilitate easy porting from existing Driver codes. +In HIP, the Ctx functions largely provide an alternate syntax for changing the active device. Most new applications will prefer to use `hipSetDevice` or the stream APIs. ## HIP Module and Ctx APIs -Rather than present two separate APIs, HIP extends the HIP API with new APIs for Modules -and Ctx control. +Rather than present two separate APIs, HIP extends the HIP API with new APIs for Modules and Ctx control. ### hipModule API -Like the CUDA Driver API, the Module API provides additional control -over how code is loaded, including options to load code from files or from in-memory pointers. -NVCC and HCC target different architectures and use different code object formats : NVCC -is `cubin` or `ptx` files, while the HCC path is the `hsaco` format. The external -compilers which generate these code objects are responsible for generating and loading -the correct code object for each platform. Notably, there is not a fat binary format that -can contain code for both NVCC and HCC platforms. The following table summarizes the -formats used on each platform: +Like the CUDA Driver API, the Module API provides additional control over how code is loaded, including options to load code from files or from in-memory pointers. +NVCC and HCC target different architectures and use different code object formats: NVCC is `cubin` or `ptx` files, while the HCC path is the `hsaco` format. +The external compilers which generate these code objects are responsible for generating and loading the correct code object for each platform. +Notably, there is not a fat binary format that can contain code for both NVCC and HCC platforms. The following table summarizes the formats used on each platform: -| Format | APIs | NVCC | HCC | -| --- | --- | --- | --- | +| Format | APIs | NVCC | HCC | +| --- | --- | --- | --- | | Code Object | hipModuleLoad, hipModuleLoadData | .cubin or PTX text | .hsaco | -| Fat Binary | hipModuleLoadFatBin | .fatbin | Under Development | +| Fat Binary | hipModuleLoadFatBin | .fatbin | Under Development | -hipcc uses NVCC and HCC to compile host codes. Both of these may embed code objects -into the final executable, and these code objects will be automatically loaded when -the application starts. -The hipModule API can be used to load additional code objects, and in this way -provides an extended capability to the automatically loaded code objects. HCC allows -both of these capabilities to be used together, if desired. Of course it is possible -to create a program with no kernels and thus no automatic loading. +`hipcc` uses NVCC and HCC to compile host codes. Both of these may embed code objects into the final executable, and these code objects will be automatically loaded when the application starts. +The hipModule API can be used to load additional code objects, and in this way provides an extended capability to the automatically loaded code objects. +HCC allows both of these capabilities to be used together, if desired. Of course it is possible to create a program with no kernels and thus no automatic loading. ### hipCtx API -HIP provides a `Ctx` API as a thin layer over the existing Device functions. This Ctx API -can be used to set the current context, or to query properties of the device associated with -the context. The current context is implicitly used by other APIs such as `hipStreamCreate`. +HIP provides a `Ctx` API as a thin layer over the existing Device functions. This Ctx API can be used to set the current context, or to query properties of the device associated with the context. +The current context is implicitly used by other APIs such as `hipStreamCreate`. ### hipify translation of CUDA Driver API -The hipify tool will convert CUDA Driver APIs for streams, events, memory management to -the equivalent HIP driver calls. For example, `cuEventCreate` will be translated to -`hipEventCreate`. Hipify also converts error code from the Driver namespace and coding -convention to the equivalent HIP error code. Thus, HIP unifies the APis for these common functions. -[hipify support for translating driver API is Under Development] +The hipify tool converts CUDA Driver APIs for streams, events, modules, devices, memory management, context, profiler to the equivalent HIP driver calls. For example, `cuEventCreate` will be translated to `hipEventCreate`. +Hipify also converts error code from the Driver namespace and coding convention to the equivalent HIP error code. Thus, HIP unifies the APIs for these common functions. -The memory copy APIs require additional explanation. The CUDA driver includes the memory -direction in the name of the API (ie `cuMemcpyH2D`) while the CUDA driver API provides -a single memory copy API with a parameter that specifies the direction and additionally -supports a "default" direction where the runtime determines the direction automatically. -HIP provides APis with both styles: for example, `hipMemcpyH2D` as well as `hipMemcpy`. -The first flavor may be faster in some cases since they avoid host overhead to detect the -different memory directions. +The memory copy API requires additional explanation. The CUDA driver includes the memory direction in the name of the API (ie `cuMemcpyH2D`) while the CUDA driver API provides a single memory copy API with a parameter that specifies the direction and additionally supports a "default" direction where the runtime determines the direction automatically. +HIP provides APIs with both styles: for example, `hipMemcpyH2D` as well as `hipMemcpy`. +The first flavor may be faster in some cases since they avoid host overhead to detect the different memory directions. -HIP defines a single error space, and uses camel-case for all errors (i.e. `hipErrorInvalidValue`). +HIP defines a single error space, and uses camel-case for all errors (i.e. `hipErrorInvalidValue`). ### HCC Implementation Notes #### .hsaco The .hsaco format used by HCC is described in more detail [here](https://github.com/RadeonOpenCompute/ROCm-ComputeABI-Doc). -An example and blog that show how to use the format is [here](http://gpuopen.com/rocm-with-harmony-combining-opencl-hcc-hsa-in-a-single-program). hsaco can be generated by hcc + extractkernel tool, -cloc, the GCN assembler, or other tools. +An example and blog that show how to use the format is [here](http://gpuopen.com/rocm-with-harmony-combining-opencl-hcc-hsa-in-a-single-program). hsaco can be generated by hcc + extractkernel tool, cloc, the GCN assembler, or other tools. #### Address Spaces -HCC defines a process-wide address space where the CPU and all devices allocate -addresses from a single unified pool. Thus addresses may be shared between contexts, and -unlike the original CUDA definition a new context does not create a new address space for -the device. +HCC defines a process-wide address space where the CPU and all devices allocate addresses from a single unified pool. +Thus addresses may be shared between contexts, and unlike the original CUDA definition a new context does not create a new address space for the device. #### Using hipModuleLaunchKernel `hipModuleLaunchKernel` is `cuLaunchKernel` in HIP world. It takes the same arguments as `cuLaunchKernel`. The argument `kernelParams` is not fully implemented for HCC. The workaround for it is, to use platform specific macros for each target. Or, `extra` argument can be used which works on both the platforms. #### Additional Information - HCC allocates staging buffers (used for unpinned copies) on a per-device basis. -- HCC creates a primary context when the HIP API is called. So in a pure driver API code, HIP/HCC will create a primary context while HIP/NVCC will have empty context stack. HIP/HCC will push primary context to context stack when it is empty. This can have subtle differences on applications which mix the runtime and driver APIs. +- HCC creates a primary context when the HIP API is called. So in a pure driver API code, HIP/HCC will create a primary context while HIP/NVCC will have empty context stack. +HIP/HCC will push primary context to context stack when it is empty. This can have subtle differences on applications which mix the runtime and driver APIs. ### NVCC Implementation Notes #### Interoperation between HIP and CUDA Driver -CUDA applications may want to mix CUDA driver code with HIP code (see example below). This -table shows the type equivalence to enable this interaction. - -|**HIP Type** |**CU Driver Type**| **CUDA Runtime Type** | -| ---- | ---- | ---- | -| hipModule | CUmodule | | -| hipFunction | CUfunction | | -| hipCtx_t | CUcontext | | -| hipDevice_t | CUdevice | | -| hipStream_t | CUstream | cudaStream_t | -| hipEvent_t | CUevent | cudaEvent_t | -| hipArray | CUarray | cudaArray | - +CUDA applications may want to mix CUDA driver code with HIP code (see example below). This table shows the type equivalence to enable this interaction. +|**HIP Type** |**CU Driver Type**|**CUDA Runtime Type**| +| ---- | ---- | ---- | +| hipModule | CUmodule | | +| hipFunction | CUfunction | | +| hipCtx_t | CUcontext | | +| hipDevice_t | CUdevice | | +| hipStream_t | CUstream | cudaStream_t | +| hipEvent_t | CUevent | cudaEvent_t | +| hipArray | CUarray | cudaArray | #### Compilation Flags -The hipModule interface does not support the hipModuleLoadEx function, which is used to control PTX compilaton options. +The hipModule interface does not support the `cuModuleLoadDataEx` function, which is used to control PTX compilation options. HCC does not use PTX and does not support the same compilation options. In fact, HCC code objects always contain fully compiled ISA and do not require additional compilation as part of the load step. -Code which requires this functionaly should use platform-specific coding, calling `cuModuleLoadEx` -on the NVCC path and hipModuleLoad on the hcc path. For example: +Code which requires this functionally should use platform-specific coding, calling `cuModuleLoadDataEx` on the NVCC path and `hipModuleLoadData` on the hcc path. +For example: ``` hipModule module; @@ -240,7 +208,7 @@ int main(){ HIP_LAUNCH_PARAM_END }; - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&con fig); + hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config); hipMemcpyDtoH(B, Bd, SIZE); for(uint32_t i=0;i + +- [CodeXL Profiling](#codexl-profiling) + * [Collecting and Viewing Traces](#collecting-and-viewing-traces) + + [Using rocm-profiler timestamp profiling](#using-rocm-profiler-timestamp-profiling) + + [Using rocm-profiler performance counter collection:](#using-rocm-profiler-performance-counter-collection) + + [Using CodeXL to view profiling results:](#using-codexl-to-view-profiling-results) + + [More information on CodeXL](#more-information-on-codexl) + * [HIP Markers](#hip-markers) + + [Profiling HIP APIs](#profiling-hip-apis) + + [Adding markers to applications](#adding-markers-to-applications) + * [Additional HIP Profiling Features](#additional-hip-profiling-features) + + [Demangling C++ Kernel Names](#demangling-c-kernel-names) + + [Controlling when profiling starts and ends](#controlling-when-profiling-starts-and-ends) + + [Reducing timeline trace output file size](#reducing-timeline-trace-output-file-size) + + [How to enable profiling at HIP build time](#how-to-enable-profiling-at-hip-build-time) +- [Tracing and Debug](#tracing-and-debug) + * [Tracing HIP APIs](#tracing-hip-apis) + + [Color](#color) + * [Using HIP_DB](#using-hip_db) + * [Using ltrace](#using-ltrace) + * [Chicken bits](#chicken-bits) + * [Debugging HIP Applications](#debugging-hip-applications) + * [General Debugging Tips](#general-debugging-tips) + + ## CodeXL Profiling @@ -92,11 +98,11 @@ HIP_PROFILE_API supports two levels of information. #### Adding markers to applications -Markers can be used to define application-specific events that will be recorded in the ATP file and displayed in the CodeXL gui. +Markers can be used to define application-specific events that will be recorded in the ATP file and displayed in the CodeXL GUI. This can be particularly useful for visualizing how the higher-level phases of application behavior relate to the lower level HIP APIs, kernel launches, and data transfers. For example, an instrumented machine learning framework could show the beginning and ending of each layer in the network. -Markers have a specific begin and end time, and can be nested. Nested calls are displayed hierarchically in the CodeXL gui, with each level of the hierarchy occupying a different row. +Markers have a specific begin and end time, and can be nested. Nested calls are displayed hierarchically in the CodeXL GUI, with each level of the hierarchy occupying a different row. The HIP APis are defined in "hip_profile.h": ``` @@ -131,7 +137,7 @@ The HIP marker API is only supported on ROCm platform. The marker macros are de This [HIP sample](samples/2_Cookbook/2_Profiler/) shows the profiler marker API used in a small application. -More information on the marker API can be found in the profiler header file and PDF in a ROCM installation: +More information on the marker API can be found in the profiler header file and PDF in a ROCm installation: - /opt/rocm/profiler/CXLActivityLogger/include/CXLActivityLogger.h - /opt/rocm/profiler/CXLActivityLogger/doc/CXLActivityLogger.pdf @@ -185,7 +191,7 @@ $ nvprof --profile-from-start-off ... This feature is under development. #### Reducing timeline trace output file size -If the application is already recording the HIP APIs, the HSA APIs are somewhat redundant and the ATP file size can be substantially reduced by not recording these APIs. HIP includes a text file that lists all of the HSA APis and can assist in this filtering: +If the application is already recording the HIP APIs, the HSA APIs are somewhat redundant and the ATP file size can be substantially reduced by not recording these APIs. HIP includes a text file that lists all of the HSA APIs and can assist in this filtering: ``` $ rocm-profiler -F hip/bin/hsa-api-filter-cxl.txt @@ -273,7 +279,7 @@ None will disable use of color control codes for both the opening and closing an This flag is primarily targeted to assist HIP development team in the development of the HIP runtime, but in some situations may be useful to HIP application developers as well. The HIP debug information is designed to print important information during the execution of a HIP API. HIP provides -different color-coded levels of debug informaton: +different color-coded levels of debug information: - api : Print the beginning and end of each HIP API, including the arguments and return codes. This is equivalent to setting HIP_TRACE_API=1. - sync : Print multi-thread and other synchronization debug information. - copy : Print which engine is doing the copy, which copy flavor is selected, information on source and destination memory. @@ -315,7 +321,7 @@ libhsa-runtime64.so.1->hsaKmtDeregisterMemory(0x7f7776d3e010, 0x7f7776d3e010, 0x ``` Some key information from the trace above. - - The trace snippet shows the execution of a hipMemcpy API, bracketed by the first and last message in the trace output. The messages show the thread id and API sequence number (`1.17`). ltrace output intermixes messages from all threads, so the HIP debug information can be useful to determine which threads are executing. + - Thy trace snippet shows the execution of a hipMemcpy API, bracketed by the first and last message in the trace output. The messages show the thread id and API sequence number (`1.17`). ltrace output intermixes messages from all threads, so the HIP debug information can be useful to determine which threads are executing. - The code flows through HIP APIs into ROCr (HSA) APIs (hsa*) and into the thunk (hsaKmt*) calls. - The HCC runtime is "libmcwamp_hsa.so" and the HSA/ROCr runtime is "libhsa-runtime64.so". - In this particular case, the memory copy is for unpinned memory, and the selected copy algorithm is to pin the host memory "in-place" before performing the copy. The signaling APIs and calls to pin ("lock", "register") the memory are readily apparent in the trace output. @@ -335,8 +341,95 @@ HIP provides 3 environment variables in the HIP_*_BLOCKING family. These introd These options cause HCC to serialize. Useful if you have libraries or code which is calling HCC kernels directly rather than using HIP. - HCC_SERIALZIE_KERNELS : 0x1=pre-serialize before each kernel launch, 0x2=post-serialize after each kernel launch., 0x3= pre- and post- serialize. -- HCC_SERIALIZE_COPY : 0x1=pre-serialize before each async copy, 0x2=post-serialize after each async copy., 0x3= pre- and post- serialize.0 +- HCC_SERIALIZE_COPY : 0x1=pre-serialize before each async copy, 0x2=post-serialize after each async copy., 0x3= pre- and post- serialize. - HSA_ENABLE_SDMA=0 : Causes host-to-device and device-to-host copies to use compute shader blit kernels rather than the dedicated DMA copy engines. Compute shader copies have low latency (typically < 5us) and can achieve approximately 80% of the bandwidth of the DMA copy engine. This flag is useful to isolate issues with the hardware copy engines. - HSA_ENABLE_INTERRUPT=0 : Causes completion signals to be detected with memory-based polling rather than interrupts. Can be useful to diagnose interrupt storm issues in the driver. - HSA_DISABLE_CACHE=1 : Disables the GPU L2 data cache. + +### Debugging HIP Applications + +- The variable "tls_tidInfo" contains the API sequence number (_apiSeqNum)- a monotonically increasing count of the HIP APIs called from this thread. This can be useful for setting conditional breakpoints. Also, each new HIP thread is mapped to monotically increasing shortTid ID. Both of these fields are displayed in the HIP debug info. +``` +(gdb) p tls_tidInfo +$32 = {_shortTid = 1, _apiSeqNum = 803} +``` + +- HCC tracks all of the application memory allocations, including those from HIP and HC's "am_alloc". +If the HCC runtime is built with debug information (HCC_RUNTIME_DEBUG=ON when building HCC), then calling the function 'hc::am_memtracker_print()' will show all memory allocations. +An optional argument specifies a void * targetPointer - the print routine will mark the allocation which contains the specified pointer with "-->" in the printed output. +This example shows a sample GDB session where we print the memory allocated by this process and mark a specified address by using the gdb "call" function.. +The gdb syntax also supports using the variable name (in this case 'dst'): +``` +(gdb) p dst +$33 = (void *) 0x5ec7e9000 +(gdb) call hc::am_memtracker_print(dst) +TargetAddress:0x5ec7e9000 + 0x504cfc000-0x504cfc00f:: allocSeqNum:1 hostPointer:0x504cfc000 devicePointer:0x504cfc000 sizeBytes:16 isInDeviceMem:0 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) +... +-->0x5ec7e9000-0x5f7e28fff:: allocSeqNum:488 hostPointer:(nil) devicePointer:0x5ec7e9000 sizeBytes:191102976 isInDeviceMem:1 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) + +``` + +To debug an explicit address, cast the address to (void*) : +``` +(gdb) call hc::am_memtracker_print((void*)0x508c7f000) +``` +- Debugging GPUVM fault. +For example: +``` +Memory access fault by GPU node-1 on address 0x5924000. Reason: Page not present or supervisor privilege. + +Program received signal SIGABRT, Aborted. +[Switching to Thread 0x7fffdffb5700 (LWP 14893)] +0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 +56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. +(gdb) bt +#0 0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 +#1 0x00007ffff205b028 in __GI_abort () at abort.c:89 +#2 0x00007ffff6f960eb in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#3 0x00007ffff6f99ea5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#4 0x00007ffff6f78107 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#5 0x00007ffff744f184 in start_thread (arg=0x7fffdffb5700) at pthread_create.c:312 +#6 0x00007ffff211b37d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 +(gdb) info threads + Id Target Id Frame + 4 Thread 0x7fffdd521700 (LWP 14895) "caffe" pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 + 3 Thread 0x7fffddd22700 (LWP 14894) "caffe" pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 +* 2 Thread 0x7fffdffb5700 (LWP 14893) "caffe" 0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 + 1 Thread 0x7ffff7fa6ac0 (LWP 14892) "caffe" 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +(gdb) thread 1 +[Switching to thread 1 (Thread 0x7ffff7fa6ac0 (LWP 14892))] +#0 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +(gdb) bt +#0 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#1 0x00007ffff6f929ba in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#2 0x00007fffe080beca in HSADispatch::waitComplete() () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#3 0x00007fffe080415f in HSADispatch::dispatchKernelAsync(Kalmar::HSAQueue*, void const*, int, bool) () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#4 0x00007fffe080238e in Kalmar::HSAQueue::dispatch_hsa_kernel(hsa_kernel_dispatch_packet_s const*, void const*, unsigned long, hc::completion_future*) () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#5 0x00007ffff7bb7559 in hipModuleLaunchKernel () from /opt/rocm/hip/lib/libhip_hcc.so +#6 0x00007ffff2e6cd2c in mlopen::HIPOCKernel::run (this=0x7fffffffb5a8, args=0x7fffffffb2a8, size=80) at /root/MIOpen/src/hipoc/hipoc_kernel.cpp:15 +... +``` + +### General Debugging Tips +- The fault will be caught by the runtime but was actually generated by an asynchronous command running on the GPU. So, the GDB backtrace will show a path in the runtime, ie inside "GI_Raise" as shown in the example above. +- To determine the true location of the fault, force the kernels to execute synchronously by seeing the environment variables HCC_SERIALIZE_KERNEL=3 HCC_SERIALIZE_COPY=3. This will force HCC to wait for the kernel to finish executing before retuning. If the fault occurs during the execution of a kernel, you can see the code which launched the kernel inside the backtrace. A bit of guesswork is required to determine which thread is actually causing the issue - typically it will the thread which is waiting inside the libhsa-runtime64.so. +- VM faults inside kernels can be caused byi: + - incorrect code (ie a for loop which extends past array boundaries), i + - memory issues - kernel arguments which are invalid (null pointers, unregistered host pointers, bad pointers). + - synchronization issues + - compiler issues (incorrect code generation from the compiler) + - runtime issues + +-- General debug tips: +- 'gdb --args' can be used to conviently pass the executable and arguments to gdb. +- From inside GDB, you can set environment variables "set env". Note the command does not use an '=' sign: +``` +(gdb) set env HIP_DB 1 +``` +Setting HIP_PRINT_ENV=1 and then running a HIP application will print the HIP environment variables, their current values, and usage info. +Setting HCC_PRINT_ENV=1 and then running a HCC application will print the HCC environment variables, their current values, and usage info. + + + diff --git a/projects/hip/docs/markdown/hip_terms2.md b/projects/hip/docs/markdown/hip_terms2.md index 9603807925..be859ffb32 100644 --- a/projects/hip/docs/markdown/hip_terms2.md +++ b/projects/hip/docs/markdown/hip_terms2.md @@ -13,7 +13,7 @@ The default device can be set with hipSetDevice. - hcc = Heterogeneous Compute Compiler (https://bitbucket.org/multicoreware/hcc/wiki/Home). - hipify - tool to convert CUDA(R) code to portable C++ code. -- hipconfig - tool to report various confoguration properties of the target platform. +- hipconfig - tool to report various configuration properties of the target platform. - nvcc = nvcc compiler, do not capitalize. - hcc = heterogeneous compute compiler, do not capitalize. diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in new file mode 100644 index 0000000000..7e4468b94a --- /dev/null +++ b/projects/hip/hip-config.cmake.in @@ -0,0 +1,65 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro OPTIONAL RESULT_VARIABLE _CMakeFindDependencyMacro_FOUND) +if (NOT _CMakeFindDependencyMacro_FOUND) + macro(find_dependency dep) + if (NOT ${dep}_FOUND) + set(cmake_fd_version) + if (${ARGC} GREATER 1) + set(cmake_fd_version ${ARGV1}) + endif() + set(cmake_fd_exact_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT) + set(cmake_fd_exact_arg EXACT) + endif() + set(cmake_fd_quiet_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(cmake_fd_quiet_arg QUIET) + endif() + set(cmake_fd_required_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(cmake_fd_required_arg REQUIRED) + endif() + find_package(${dep} ${cmake_fd_version} + ${cmake_fd_exact_arg} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} + ) + string(TOUPPER ${dep} cmake_dep_upper) + if (NOT ${dep}_FOUND AND NOT ${cmake_dep_upper}_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) + return() + endif() + set(cmake_fd_version) + set(cmake_fd_required_arg) + set(cmake_fd_quiet_arg) + set(cmake_fd_exact_arg) + endif() + endmacro() +endif() + + +set_and_check( hip_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) +set_and_check( hip_INCLUDE_DIRS "${hip_INCLUDE_DIR}" ) +set_and_check( hip_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) +set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" ) + +set_and_check(hip_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") +set_and_check(hip_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") + +find_dependency(hcc) +include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) + +set( hip_LIBRARIES hip::hip_hcc) +set( hip_LIBRARY ${hip_LIBRARIES}) + +set(HIP_INCLUDE_DIR ${hip_INCLUDE_DIR}) +set(HIP_INCLUDE_DIRS ${hip_INCLUDE_DIRS}) +set(HIP_LIB_INSTALL_DIR ${hip_LIB_INSTALL_DIR}) +set(HIP_BIN_INSTALL_DIR ${hip_BIN_INSTALL_DIR}) +set(HIP_LIBRARIES ${hip_LIBRARIES}) +set(HIP_LIBRARY ${hip_LIBRARY}) +set(HIP_HIPCC_EXECUTABLE ${hip_HIPCC_EXECUTABLE}) +set(HIP_HIPCONFIG_EXECUTABLE ${hip_HIPCONFIG_EXECUTABLE}) + diff --git a/projects/hip/hipify-clang/CMakeLists.txt b/projects/hip/hipify-clang/CMakeLists.txt index 14dc9c5d17..a02b91407f 100644 --- a/projects/hip/hipify-clang/CMakeLists.txt +++ b/projects/hip/hipify-clang/CMakeLists.txt @@ -19,6 +19,9 @@ else() add_llvm_executable(hipify-clang src/Cuda2Hip.cpp) find_program(LIT_COMMAND lit) + set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++) + set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang) + # Link against LLVM and CLANG tools libraries target_link_libraries(hipify-clang clangASTMatchers diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 6e58f719b7..c0d74dbe48 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -13,24 +13,31 @@ `hipify-clang` is a clang-based tool which can automate the translation of CUDA source code into portable HIP C++. The tool can automatically add extra HIP arguments (notably the "hipLaunchParm" required at the beginning of every HIP kernel call). -`hipify-clang` has some additional dependencies explained below and can be built as a separate make step. The instructions below are specifically for **Ubuntu 14.04** +`hipify-clang` has some additional dependencies explained below and can be built as a separate make step. The instructions below are specifically for **Ubuntu 14.04** and **Ubuntu 16.04**. ### Build and install - Download and unpack clang+llvm 3.8 binary package preqrequisite. + +**Ubuntu 14.04**: ```shell wget http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz tar xvfJ clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz ``` +**Ubuntu 16.04**: +```shell +wget http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz +tar xvfJ clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz +``` - Enable build of hipify-clang and specify path to LLVM. -Note HIPIFY_CLANG_LLVM_DIR must be a full absolute path to the location extracted above. Here's an example assuming we extract the clang 3.8 package into ~/HIP/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/ +Note HIPIFY_CLANG_LLVM_DIR must be a full absolute path to the location extracted above. Here's an example assuming we extract the clang 3.8 package into ~/HIP/clang+llvm-3.8.0/ ```shell cd HIP mkdir build cd build -cmake -DHIPIFY_CLANG_LLVM_DIR=~/HIP/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/ -DCMAKE_BUILD_TYPE=Release .. +cmake -DHIPIFY_CLANG_LLVM_DIR=~/HIP/clang+llvm-3.8.0/ -DCMAKE_BUILD_TYPE=Release .. make make install ``` @@ -41,17 +48,35 @@ make install In the case when `hipify-clang` doesn't find cuda headers, it reports various errors about unknown keywords (e.g. '\__global\__'), API function names (e.g. 'cudaMalloc'), syntax (e.g. 'foo<<<1,n>>>(...)'), etc. -To install CUDA headers, download the "deb(network)" variant of the target installer from https://developer.nvidia.com/cuda-downloads. The commands below show how to download and install a recent version from http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb. +To install CUDA headers, download the "deb(network)" variant of the target installer. + +**Ubuntu 14.04**: ```shell wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 ``` +**Ubuntu 16.04**: +```shell +wget http://archive.ubuntu.com/ubuntu/pool/multiverse/n/nvidia-cuda-toolkit/nvidia-cuda-toolkit_7.5.18-0ubuntu1_amd64.deb +sudo dpkg -i nvidia-cuda-toolkit_7.5.18-0ubuntu1_amd64.deb +sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 +``` +To set additional options like Language Selection (only "-x cuda" is supported), Preprocessor Definition (-D), Include Path (-I), etc., options delimiter "--" should be used before them, for instance: -#### Disclaimer +```shell +./hipify-clang -print-stats sort_kernel.cu -- -x cuda -I/srv/git/HIP/include -I/usr/local/cuda-7.5/include -DX=1 +``` + +Delimiter "--" is used to separate hipify-clang options (before the delimiter) from clang options (after the delimiter). It is strongly recommended to always specify the delimiter, even if there are no clang specific options at all, in order to avoid possible errors regarding compilation database; in such case delimeter should be the last option in hipify-clang's command line. + +Option "-x clang" is also worth specifying in order to convert source CUDA files with extensions other than standard extensions (*.cu, *.cuh). + +## Disclaimer The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. Terms and limitations applicable to the purchase or use of AMD's products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale. AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. -Copyright (c) 2014-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2014-2017 Advanced Micro Devices, Inc. All rights reserved. + diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index c66a2b1b87..5a2940322e 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -47,6 +47,10 @@ THE SOFTWARE. #include #include #include +#include +#include +#include +#include using namespace clang; using namespace clang::ast_matchers; @@ -54,6 +58,7 @@ using namespace clang::tooling; using namespace llvm; #define DEBUG_TYPE "cuda2hip" +#define HIP_UNSUPPORTED -1 enum ConvTypes { CONV_DRIVER = 0, @@ -65,12 +70,18 @@ enum ConvTypes { CONV_SPECIAL_FUNC, CONV_STREAM, CONV_EVENT, + CONV_OCCUPANCY, CONV_CONTEXT, CONV_MODULE, CONV_CACHE, + CONV_EXEC, CONV_ERR, CONV_DEF, CONV_TEX, + CONV_GL, + CONV_GRAPHICS, + CONV_SURFACE, + CONV_JIT, CONV_OTHER, CONV_INCLUDE, CONV_INCLUDE_CUDA_MAIN_H, @@ -81,10 +92,12 @@ enum ConvTypes { }; const char *counterNames[CONV_LAST] = { - "driver", "dev", "mem", "kern", "coord_func", "math_func", - "special_func", "stream", "event", "ctx", "module", "cache", - "err", "def", "tex", "other", "include", "include_cuda_main_header", + "driver", "dev", "mem", "kern", "coord_func", "math_func", + "special_func", "stream", "event", "occupancy", "ctx", "module", + "cache", "exec", "err", "def", "tex", "gl", + "graphics", "surface", "jit", "other", "include", "include_cuda_main_header", "type", "literal", "numeric_literal"}; + enum ApiTypes { API_DRIVER = 0, API_RUNTIME, @@ -93,11 +106,68 @@ enum ApiTypes { }; const char *apiNames[API_LAST] = { - "CUDA", "CUDA RT", "CUBLAS"}; + "CUDA Driver API", "CUDA RT API", "CUBLAS API"}; + +// Set up the command line options +static cl::OptionCategory ToolTemplateCategory("CUDA to HIP source translator options"); + +static cl::opt OutputFilename("o", + cl::desc("Output filename"), + cl::value_desc("filename"), + cl::cat(ToolTemplateCategory)); + +static cl::opt Inplace("inplace", + cl::desc("Modify input file inplace, replacing input with hipified output, save backup in .prehip file"), + cl::value_desc("inplace"), + cl::cat(ToolTemplateCategory)); + +static cl::opt NoBackup("no-backup", + cl::desc("Don't create a backup file for the hipified source"), + cl::value_desc("no-backup"), + cl::cat(ToolTemplateCategory)); + +static cl::opt NoOutput("no-output", + cl::desc("Don't write any translated output to stdout"), + cl::value_desc("no-output"), + cl::cat(ToolTemplateCategory)); + +static cl::opt PrintStats("print-stats", + cl::desc("Print translation statistics"), + cl::value_desc("print-stats"), + cl::cat(ToolTemplateCategory)); + +static cl::opt OutputStatsFilename("o-stats", + cl::desc("Output filename for statistics"), + cl::value_desc("filename"), + cl::cat(ToolTemplateCategory)); + +static cl::opt Examine("examine", + cl::desc("Combines -no-output and -print-stats options"), + cl::value_desc("examine"), + cl::cat(ToolTemplateCategory)); + +static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); namespace { +uint64_t countRepsTotal[CONV_LAST] = { 0 }; +uint64_t countApiRepsTotal[API_LAST] = { 0 }; +uint64_t countRepsTotalUnsupported[CONV_LAST] = { 0 }; +uint64_t countApiRepsTotalUnsupported[API_LAST] = { 0 }; +std::map cuda2hipConvertedTotal; +std::map cuda2hipUnconvertedTotal; + +struct hipCounter { + StringRef hipName; + ConvTypes countType; + ApiTypes countApiType; + int unsupported; +}; + struct cuda2hipMap { + std::map cuda2hipRename; + std::set cudaExcludes; + cuda2hipMap() { // Replacement Excludes @@ -120,210 +190,591 @@ struct cuda2hipMap { cuda2hipRename["cublas_v2.h"] = {"hipblas.h", CONV_INCLUDE, API_BLAS}; // Error codes and return types - cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaError"] = {"hipError", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["cudaError_enum"] = {"hipError_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaError"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; - // CUDA Driver API error code only - cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; + // CUDA Driver API error codes only + cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; // 201 + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; // 202 + cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; // 207 + cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; // 208 + cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; // 210 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; // 211 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; // 212 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; // 213 + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; // 216 + cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; // 300 + cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; // 301 + cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; // 500 // CUDA RT API error code only - cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 5 + cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 8 + cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 9 + cuda2hipRename["cudaErrorInvalidPitchValue"] = {"hipErrorInvalidPitchValue", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 12 + cuda2hipRename["cudaErrorInvalidSymbol"] = {"hipErrorInvalidSymbol", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 13 + cuda2hipRename["cudaErrorInvalidHostPointer"] = {"hipErrorInvalidHostPointer", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 16 + cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; // 17 + cuda2hipRename["cudaErrorInvalidTexture"] = {"hipErrorInvalidTexture", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 18 + cuda2hipRename["cudaErrorInvalidTextureBinding"] = {"hipErrorInvalidTextureBinding", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 19 + cuda2hipRename["cudaErrorInvalidChannelDescriptor"] = {"hipErrorInvalidChannelDescriptor", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 20 + cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 21 + cuda2hipRename["cudaErrorAddressOfConstant"] = {"hipErrorAddressOfConstant", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 22 + cuda2hipRename["cudaErrorTextureFetchFailed"] = {"hipErrorTextureFetchFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 23 + cuda2hipRename["cudaErrorTextureNotBound"] = {"hipErrorTextureNotBound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 24 + cuda2hipRename["cudaErrorSynchronizationError"] = {"hipErrorSynchronizationError", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 25 + cuda2hipRename["cudaErrorInvalidFilterSetting"] = {"hipErrorInvalidFilterSetting", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 26 + cuda2hipRename["cudaErrorInvalidNormSetting"] = {"hipErrorInvalidNormSetting", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 27 + cuda2hipRename["cudaErrorMixedDeviceExecution"] = {"hipErrorMixedDeviceExecution", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 28 + // Deprecated as of CUDA 4.1 + cuda2hipRename["cudaErrorNotYetImplemented"] = {"hipErrorNotYetImplemented", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 31 + // Deprecated as of CUDA 3.1 + cuda2hipRename["cudaErrorMemoryValueTooLarge"] = {"hipErrorMemoryValueTooLarge", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 32 + cuda2hipRename["cudaErrorInsufficientDriver"] = {"hipErrorInsufficientDriver", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 35 + cuda2hipRename["cudaErrorSetOnActiveProcess"] = {"hipErrorSetOnActiveProcess", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 36 + cuda2hipRename["cudaErrorInvalidSurface"] = {"hipErrorInvalidSurface", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 37 + cuda2hipRename["cudaErrorDuplicateVariableName"] = {"hipErrorDuplicateVariableName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 43 + cuda2hipRename["cudaErrorDuplicateTextureName"] = {"hipErrorDuplicateTextureName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 44 + cuda2hipRename["cudaErrorDuplicateSurfaceName"] = {"hipErrorDuplicateSurfaceName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 45 + cuda2hipRename["cudaErrorDevicesUnavailable"] = {"hipErrorDevicesUnavailable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 46 + cuda2hipRename["cudaErrorIncompatibleDriverContext"] = {"hipErrorIncompatibleDriverContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 49 + cuda2hipRename["cudaErrorDeviceAlreadyInUse"] = {"hipErrorDeviceAlreadyInUse", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 54 + cuda2hipRename["cudaErrorAssert"] = {"hipErrorAssert", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 59 + cuda2hipRename["cudaErrorTooManyPeers"] = {"hipErrorTooManyPeers", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 60 + cuda2hipRename["cudaErrorLaunchMaxDepthExceeded"] = {"hipErrorLaunchMaxDepthExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 65 + cuda2hipRename["cudaErrorLaunchFileScopedTex"] = {"hipErrorLaunchFileScopedTex", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 66 + cuda2hipRename["cudaErrorLaunchFileScopedSurf"] = {"hipErrorLaunchFileScopedSurf", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 67 + cuda2hipRename["cudaErrorSyncDepthExceeded"] = {"hipErrorSyncDepthExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 68 + cuda2hipRename["cudaErrorLaunchPendingCountExceeded"] = {"hipErrorLaunchPendingCountExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 69 + cuda2hipRename["cudaErrorNotPermitted"] = {"hipErrorNotPermitted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 70 + cuda2hipRename["cudaErrorNotSupported"] = {"hipErrorNotSupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 71 + cuda2hipRename["cudaErrorHardwareStackError"] = {"hipErrorHardwareStackError", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 72 + cuda2hipRename["cudaErrorIllegalInstruction"] = {"hipErrorIllegalInstruction", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 73 + cuda2hipRename["cudaErrorMisalignedAddress"] = {"hipErrorMisalignedAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 74 + cuda2hipRename["cudaErrorInvalidAddressSpace"] = {"hipErrorInvalidAddressSpace", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 75 + cuda2hipRename["cudaErrorInvalidPc"] = {"hipErrorInvalidPc", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 76 + cuda2hipRename["cudaErrorStartupFailure"] = {"hipErrorStartupFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 0x7f + // Deprecated as of CUDA 4.1 + cuda2hipRename["cudaErrorApiFailureBase"] = {"hipErrorApiFailureBase", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 10000 - cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorNotInitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; // 0 + cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; // 0 - cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; // 1 + cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; // 11 - cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; // 2 + cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; // 2 - cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; // 3 + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; // 3 - cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; // 4 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 29 - cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; // 5 + cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 55 - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; // 6 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 56 - cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; // 7 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 57 - cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; // 8 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 58 - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; // 100 + cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; // 38 - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; // 101 + cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; // 10 - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; // 200 + cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 47 - cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; // 205 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorMapBufferObjectFailed"] = {"hipErrorMapFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 14 - cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; // 206 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorUnmapBufferObjectFailed"] = {"hipErrorUnmapFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 15 - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; // 209 + cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 48 - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; // 214 + cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 39 - cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; // 215 + cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 42 - cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; // 217 + cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 64 - cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; // 218 + cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 78 - cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; // 219 + cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 79 - cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; // 302 + cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 40 - cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; // 303 + cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 41 + + cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; // 304 + cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 63 + + cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; // 400 + cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; // 33 + + cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; // 600 + cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; // 34 + + cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; // 700 + cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 77 + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; // 719 + cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 4 + + cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 6 + + cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; // 7 + + cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; // 30 + +// cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; +// cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; // 50 + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; // 51 cuda2hipRename["CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; // 61 - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; // 62 ///////////////////////////// CUDA DRIVER API ///////////////////////////// + // enums + cuda2hipRename["CUDA_ARRAY3D_DESCRIPTOR"] = {"HIP_ARRAY3D_DESCRIPTOR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_ARRAY_DESCRIPTOR"] = {"HIP_ARRAY_DESCRIPTOR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY2D"] = {"HIP_MEMCPY2D", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY3D"] = {"HIP_MEMCPY3D", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY3D_PEER"] = {"HIP_MEMCPY3D_PEER", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_POINTER_ATTRIBUTE_P2P_TOKENS"] = {"HIP_POINTER_ATTRIBUTE_P2P_TOKENS", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_RESOURCE_DESC"] = {"HIP_RESOURCE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_RESOURCE_VIEW_DESC"] = {"HIP_RESOURCE_VIEW_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + + cuda2hipRename["CUipcEventHandle"] = {"hipIpcEventHandle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUipcMemHandle"] = {"hipIpcMemHandle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + + + + cuda2hipRename["CUaddress_mode"] = {"hipAddress_mode", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TR_ADDRESS_MODE_WRAP"] = {"HIP_TR_ADDRESS_MODE_WRAP", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["CU_TR_ADDRESS_MODE_CLAMP"] = {"HIP_TR_ADDRESS_MODE_CLAMP", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["CU_TR_ADDRESS_MODE_MIRROR"] = {"HIP_TR_ADDRESS_MODE_MIRROR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["CU_TR_ADDRESS_MODE_BORDER"] = {"HIP_TR_ADDRESS_MODE_BORDER", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 3 + + cuda2hipRename["CUarray_cubemap_face"] = {"hipArray_cubemap_face", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_X"] = {"HIP_CUBEMAP_FACE_POSITIVE_X", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_X"] = {"HIP_CUBEMAP_FACE_NEGATIVE_X", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_Y"] = {"HIP_CUBEMAP_FACE_POSITIVE_Y", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_Y"] = {"HIP_CUBEMAP_FACE_NEGATIVE_Y", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_Z"] = {"HIP_CUBEMAP_FACE_POSITIVE_Z", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_Z"] = {"HIP_CUBEMAP_FACE_NEGATIVE_Z", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x05 + + cuda2hipRename["CUarray_format"] = {"hipArray_format", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT8"] = {"HIP_AD_FORMAT_UNSIGNED_INT8", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT16"] = {"HIP_AD_FORMAT_UNSIGNED_INT16", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT32"] = {"HIP_AD_FORMAT_UNSIGNED_INT32", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT8"] = {"HIP_AD_FORMAT_SIGNED_INT8", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT16"] = {"HIP_AD_FORMAT_SIGNED_INT16", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x09 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT32"] = {"HIP_AD_FORMAT_SIGNED_INT32", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x0a + cuda2hipRename["CU_AD_FORMAT_HALF"] = {"HIP_AD_FORMAT_HALF", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 + cuda2hipRename["CU_AD_FORMAT_FLOAT"] = {"HIP_AD_FORMAT_FLOAT", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 + // Compute mode + cuda2hipRename["CUcomputemode"] = {"hipComputemode", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_RUNTIME ANALOGUE (cudaComputeMode) + cuda2hipRename["CU_COMPUTEMODE_DEFAULT"] = {"hipComputeModeDefault", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["CU_COMPUTEMODE_EXCLUSIVE"] = {"hipComputeModeExclusive", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["CU_COMPUTEMODE_PROHIBITED"] = {"hipComputeModeProhibited", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["CU_COMPUTEMODE_EXCLUSIVE_PROCESS"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 + // Context flags + cuda2hipRename["CUctx_flags"] = {"hipCctx_flags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_CTX_SCHED_AUTO"] = {"HIP_CTX_SCHED_AUTO", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 + cuda2hipRename["CU_CTX_SCHED_SPIN"] = {"HIP_CTX_SCHED_SPIN", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_CTX_SCHED_YIELD"] = {"HIP_CTX_SCHED_YIELD", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_CTX_SCHED_BLOCKING_SYNC"] = {"HIP_CTX_SCHED_BLOCKING_SYNC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CTX_BLOCKING_SYNC"] = {"HIP_CTX_BLOCKING_SYNC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CTX_SCHED_MASK"] = {"HIP_CTX_SCHED_MASK", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x07 + cuda2hipRename["CU_CTX_MAP_HOST"] = {"HIP_CTX_MAP_HOST", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 + cuda2hipRename["CU_CTX_LMEM_RESIZE_TO_MAX"] = {"HIP_CTX_LMEM_RESIZE_TO_MAX", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 + cuda2hipRename["CU_CTX_FLAGS_MASK"] = {"HIP_CTX_FLAGS_MASK", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1f + + // Defines + cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_POINTER"] = {"HIP_LAUNCH_PARAM_BUFFER_POINTER", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_SIZE"] = {"HIP_LAUNCH_PARAM_BUFFER_SIZE", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_LAUNCH_PARAM_END"] = {"HIP_LAUNCH_PARAM_END", CONV_DEV, API_DRIVER}; + // Types // NOTE: CUdevice might be changed to typedef int in the future. - cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaDeviceAttr) + cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaDeviceAttr) + // unsupported yet by HIP + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (cudaDevAttrMaxThreadsPerBlock = 1) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimX = 2) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimY = 3) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 4 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimZ = 4) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 5 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimX =5) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 6 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimY = 6) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 7 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimZ - 7) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 // API_Runtime ANALOGUE (cudaDevAttrMaxSharedMemoryPerBlock = 8) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 9 // API_Runtime ANALOGUE (cudaDevAttrTotalConstantMemory = 9) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 10 // API_Runtime ANALOGUE (cudaDevAttrWarpSize = 10) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_PITCH"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 11 // API_Runtime ANALOGUE (cudaDevAttrMaxPitch = 11) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 12 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerBlock = 12) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 12 + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 13 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerBlock = 13) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 14 // API_Runtime ANALOGUE (cudaDevAttrTextureAlignment = 14) + // Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GPU_OVERLAP"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 15 // API_Runtime ANALOGUE (cudaDevAttrGpuOverlap = 15) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 16 // API_Runtime ANALOGUE (cudaDevAttrMultiProcessorCount = 16) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 17 // API_Runtime ANALOGUE (cudaDevAttrKernelExecTimeout = 17) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_INTEGRATED"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 18 // API_Runtime ANALOGUE (cudaDevAttrIntegrated = 18) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 19 // API_Runtime ANALOGUE (cudaDevAttrCanMapHostMemory = 19) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; // 20 // API_Runtime ANALOGUE (cudaDevAttrComputeMode = 20) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 21 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DWidth = 21) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 22 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DWidth = 22) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 23 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DHeight = 23) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 24 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DWidth = 24) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 25 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DHeight = 25) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 26 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DDepth = 26) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 27 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredWidth = 27) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 28 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredHeight = 28) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 29 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredLayers = 29) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 27 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredWidth = 27) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 28 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredHeight = 28) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 29 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredLayers = 29) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 30 // API_Runtime ANALOGUE (cudaDevAttrSurfaceAlignment = 30) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; // 31 // API_Runtime ANALOGUE (cudaDevAttrConcurrentKernels = 31) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ECC_ENABLED"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 32 // API_Runtime ANALOGUE (cudaDevAttrEccEnabled = 32) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; // 33 // API_Runtime ANALOGUE (cudaDevAttrPciBusId = 33) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; // 34 // API_Runtime ANALOGUE (cudaDevAttrPciDeviceId = 34) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TCC_DRIVER"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 35 // API_Runtime ANALOGUE (cudaDevAttrTccDriver = 35) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 36 // API_Runtime ANALOGUE (cudaDevAttrMemoryClockRate = 36) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; // 37 // API_Runtime ANALOGUE (cudaDevAttrGlobalMemoryBusWidth = 37) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; // 38 // API_Runtime ANALOGUE (cudaDevAttrL2CacheSize = 38) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; // 39 // API_Runtime ANALOGUE (cudaDevAttrMaxThreadsPerMultiProcessor = 39) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 40 // API_Runtime ANALOGUE (cudaDevAttrAsyncEngineCount = 40) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 41 // API_Runtime ANALOGUE (cudaDevAttrUnifiedAddressing = 41) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 42 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLayeredWidth = 42) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 43 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLayeredLayers = 43) + // deprecated, do not use + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER"] = {"hipDeviceAttributeCanTex2DGather", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 44 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 45 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DGatherWidth = 45) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 46 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DGatherHeight = 46) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 47 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DWidthAlt = 47) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 48 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DHeightAlt = 48) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 49 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DDepthAlt = 49) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 50 // API_Runtime ANALOGUE (cudaDevAttrPciDomainId = 50) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 51 // API_Runtime ANALOGUE (cudaDevAttrTexturePitchAlignment = 51) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 52 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapWidth = 52) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 53 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapLayeredWidth = 53) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 54 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapLayeredLayers = 54) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 55 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DWidth = 55) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 56 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DWidth = 56) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 57 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DHeight = 57) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 58 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DWidth = 58) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 59 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DHeight = 59) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 60 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DDepth = 60) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 61 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DLayeredWidth = 61) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 62 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DLayeredLayers = 62) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 63 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredWidth = 63) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 64 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredHeight = 64) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 65 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredLayers = 65) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 66 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapWidth = 66) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 67 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 68 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 69 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLinearWidth = 69) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 70 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearWidth = 70) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 71 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearHeight = 71) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 72 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearPitch = 72) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 73 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DMipmappedWidth = 73) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 74 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DMipmappedHeight = 74) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; // 75 // API_Runtime ANALOGUE (cudaDevAttrComputeCapabilityMajor = 75) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; // 76 // API_Runtime ANALOGUE (cudaDevAttrComputeCapabilityMinor = 76) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 77 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DMipmappedWidth = 77) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 78 // API_Runtime ANALOGUE (cudaDevAttrStreamPrioritiesSupported = 78) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 79 // API_Runtime ANALOGUE (cudaDevAttrGlobalL1CacheSupported = 79) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 80 // API_Runtime ANALOGUE (cudaDevAttrLocalL1CacheSupported = 80) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; // 81 // API_Runtime ANALOGUE (cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 82 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerMultiprocessor = 82) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 83 // API_Runtime ANALOGUE (cudaDevAttrManagedMemory = 83) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; // 84 // API_Runtime ANALOGUE (cudaDevAttrIsMultiGpuBoard = 84) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID"] = {"hipDeviceAttributeMultiGpuBoardGroupId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 85 // API_Runtime ANALOGUE (cudaDevAttrMultiGpuBoardGroupID = 85) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX"] = {"hipDeviceAttributeMax", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 86 // API_Runtime ANALOGUE (no) - cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS"] = {"hipDeviceAttributePageableMemoryAccess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS"] = {"hipDeviceAttributeConcurrentManagedAccess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED"] = {"hipDeviceAttributeComputePreemptionSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; - - cuda2hipRename["CUdevprop_st"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevprop"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevprop_st"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevprop"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; // TODO: Analogues enum is needed in HIP. Couldn't map enum to struct hipPointerAttribute_t. // TODO: Do for Pointer Attributes the same as for Device Attributes. - // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; - // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; + // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_CONTEXT"] = {"hipPointerAttributeContext", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_MEMORY_TYPE"] = {"hipPointerAttributeMemoryType", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_DEVICE_POINTER"] = {"hipPointerAttributeDevicePointer", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_HOST_POINTER"] = {"hipPointerAttributeHostPointer", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 4 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_P2P_TOKENS"] = {"hipPointerAttributeP2pTokens", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 5 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_SYNC_MEMOPS"] = {"hipPointerAttributeSyncMemops", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 6 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_BUFFER_ID"] = {"hipPointerAttributeBufferId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 7 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_IS_MANAGED"] = {"hipPointerAttributeIsManaged", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 // API_Runtime ANALOGUE (no) - cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; + + // pointer to CUfunc_st + cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; + // TODO: in HIP ihipModuleSymbol_t should be declared in hip_runtime_api.h, not in hcc_detail/hip_runtime_api.h, as it's analogue CUfunc_st is declared also in cuda.h + // ToDO: examples are needed with CUfunc_st + // cuda2hipRename["CUfunc_st"] = {"ihipModuleSymbol_t", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER}; - // cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipFuncAttributeMaxThreadsPerBlocks", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES"] = {"hipFuncAttributeSharedSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES"] = {"hipFuncAttributeConstSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES"] = {"hipFuncAttributeLocalSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_NUM_REGS"] = {"hipFuncAttributeNumRegs", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_PTX_VERSION"] = {"hipFuncAttributePtxVersion", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_BINARY_VERSION"] = {"hipFuncAttributeBinaryVersion", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_CACHE_MODE_CA"] = {"hipFuncAttributeCacheModeCA", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_MAX"] = {"hipFuncAttributeMax", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CUfunc_cache_enum"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUfunc_cache"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_NONE"] = {"hipFuncCachePreferNone", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_SHARED"] = {"hipFuncCachePreferShared", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_L1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_EQUAL"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_DRIVER}; + // enum CUgraphicsMapResourceFlags/CUgraphicsMapResourceFlags_enum + cuda2hipRename["CUgraphicsMapResourceFlags"] = {"hipGraphicsMapFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsMapFlags) + cuda2hipRename["CUgraphicsMapResourceFlags_enum"] = {"hipGraphicsMapFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsMapFlags) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE"] = {"hipGraphicsMapFlagsNone", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsNone = 0) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY"] = {"hipGraphicsMapFlagsReadOnly", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsReadOnly = 1) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsWriteDiscard = 2) - cuda2hipRename["CUsharedconfig_enum"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUsharedconfig"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; + // enum CUgraphicsRegisterFlags/CUgraphicsRegisterFlags_enum + cuda2hipRename["CUgraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsRegisterFlags) + cuda2hipRename["CUgraphicsRegisterFlags_enum"] = {"hipGraphicsRegisterFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsRegisterFlags) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE"] = {"hipGraphicsRegisterFlagsNone", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsNone = 0) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsReadOnly = 1) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsWriteDiscard = 2) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsSurfaceLoadStore = 4) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsTextureGather = 8) - cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - // Event Flags - cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_DISABLE_TIMING"] = {"hipEventDisableTiming", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_INTERPROCESS"] = {"hipEventInterprocess", CONV_EVENT, API_DRIVER}; + // enum CUoccupancy_flags/CUoccupancy_flags_enum + cuda2hipRename["CUoccupancy_flags"] = {"hipOccupancyFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUoccupancy_flags_enum"] = {"hipOccupancyFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_OCCUPANCY_DEFAULT"] = {"hipOccupancyDefault", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaOccupancyDefault = 0x0) + cuda2hipRename["CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE"] = {"hipOccupancyDisableCachingOverride", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaOccupancyDisableCachingOverride = 0x1) - cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; + + + cuda2hipRename["CUfunc_cache_enum"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaFuncCache) + cuda2hipRename["CUfunc_cache"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaFuncCache) + cuda2hipRename["CU_FUNC_CACHE_PREFER_NONE"] = {"hipFuncCachePreferNone", CONV_CACHE, API_DRIVER}; // 0x00 // API_Runtime ANALOGUE (cudaFilterModePoint = 0) + cuda2hipRename["CU_FUNC_CACHE_PREFER_SHARED"] = {"hipFuncCachePreferShared", CONV_CACHE, API_DRIVER}; // 0x01 // API_Runtime ANALOGUE (cudaFuncCachePreferShared = 1) + cuda2hipRename["CU_FUNC_CACHE_PREFER_L1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_DRIVER}; // 0x02 // API_Runtime ANALOGUE (cudaFuncCachePreferL1 = 2) + cuda2hipRename["CU_FUNC_CACHE_PREFER_EQUAL"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_DRIVER}; // 0x03 // API_Runtime ANALOGUE (cudaFuncCachePreferEqual = 3) + + // enum CUipcMem_flags/CUipcMem_flags_enum + cuda2hipRename["CUipcMem_flags"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUipcMem_flags_enum"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS"] = {"hipIpcMemLazyEnablePeerAccess", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1 // API_Runtime ANALOGUE (cudaIpcMemLazyEnablePeerAccess = 0x01) + + // enum CUipcMem_flags/CUipcMem_flags_enum + cuda2hipRename["CUipcMem_flags"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + + // JIT + // enum CUjit_cacheMode/CUjit_cacheMode_enum + cuda2hipRename["CUjit_cacheMode"] = {"hipJitCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_cacheMode_enum"] = {"hipJitCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_NONE"] = {"hipJitCacheModeOptionNone", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_CG"] = {"hipJitCacheModeOptionCG", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_CA"] = {"hipJitCacheModeOptionCA", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_fallback/CUjit_fallback_enum + cuda2hipRename["CUjit_fallback"] = {"hipJitFallback", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_fallback_enum"] = {"hipJitFallback", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_PREFER_PTX"] = {"hipJitFallbackPreferPtx", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_PREFER_BINARY"] = {"hipJitFallbackPreferBinary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_option/CUjit_option_enum + cuda2hipRename["CUjit_option"] = {"hipJitOption", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_option_enum"] = {"hipJitOption", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_MAX_REGISTERS"] = {"hipJitOptionMaxRegisters", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_THREADS_PER_BLOCK"] = {"hipJitOptionThreadsPerBlock", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_WALL_TIME"] = {"hipJitOptionWallTime", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INFO_LOG_BUFFER"] = {"hipJitOptionInfoLogBuffer", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES"] = {"hipJitOptionInfoLogBufferSizeBytes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_ERROR_LOG_BUFFER"] = {"hipJitOptionErrorLogBuffer", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES"] = {"hipJitOptionErrorLogBufferSizeBytes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_OPTIMIZATION_LEVEL"] = {"hipJitOptionOptimizationLevel", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_TARGET_FROM_CUCONTEXT"] = {"hipJitOptionTargetFromContext", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_TARGET"] = {"hipJitOptionTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_FALLBACK_STRATEGY"] = {"hipJitOptionFallbackStrategy", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_GENERATE_DEBUG_INFO"] = {"hipJitOptionGenerateDebugInfo", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_LOG_VERBOSE"] = {"hipJitOptionLogVerbose", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_GENERATE_LINE_INFO"] = {"hipJitOptionLogVerbose", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_MODE"] = {"hipJitOptionCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_NUM_OPTIONS"] = {"hipJitOptionNumOptions", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_target/CUjit_target_enum + cuda2hipRename["CUjit_target"] = {"hipJitTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_target_enum"] = {"hipJitTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_10"] = {"hipJitTargetCompute10", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_11"] = {"hipJitTargetCompute11", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_12"] = {"hipJitTargetCompute12", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_13"] = {"hipJitTargetCompute13", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_20"] = {"hipJitTargetCompute20", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_21"] = {"hipJitTargetCompute21", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_30"] = {"hipJitTargetCompute30", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_32"] = {"hipJitTargetCompute32", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_35"] = {"hipJitTargetCompute35", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_37"] = {"hipJitTargetCompute37", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_50"] = {"hipJitTargetCompute50", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_52"] = {"hipJitTargetCompute52", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjitInputType/CUjitInputType_enum + cuda2hipRename["CUjitInputType"] = {"hipJitInputType", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjitInputType_enum"] = {"hipJitInputType", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_CUBIN"] = {"hipJitInputTypeBin", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_PTX"] = {"hipJitInputTypePtx", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_FATBINARY"] = {"hipJitInputTypeFatBinary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_OBJECT"] = {"hipJitInputTypeObject", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_LIBRARY"] = {"hipJitInputTypeLibrary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_NUM_INPUT_TYPES"] = {"hipJitInputTypeNumInputTypes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + + // Limits + cuda2hipRename["CUlimit"] = {"hipLimit_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaLimit) + cuda2hipRename["CUlimit_enum"] = {"hipLimit_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaLimit) + cuda2hipRename["CU_LIMIT_STACK_SIZE"] = {"hipLimitStackSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaLimitStackSize = 0x00) + cuda2hipRename["CU_LIMIT_PRINTF_FIFO_SIZE"] = {"hipLimitPrintfFifoSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaLimitPrintfFifoSize = 0x01) + cuda2hipRename["CU_LIMIT_MALLOC_HEAP_SIZE"] = {"hipLimitMallocHeapSize", CONV_TYPE, API_DRIVER}; // 0x02 // API_Runtime ANALOGUE (cudaLimitMallocHeapSize = 0x02) + cuda2hipRename["CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH"] = {"hipLimitDevRuntimeSyncDepth", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaLimitDevRuntimeSyncDepth = 0x03) + cuda2hipRename["CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT"] = {"hipLimitDevRuntimePendingLaunchCount", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaLimitDevRuntimePendingLaunchCount = 0x04) + cuda2hipRename["CU_LIMIT_STACK_SIZE"] = {"hipLimitStackSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + + // enum CUmemAttach_flags/CUmemAttach_flags_enum + cuda2hipRename["CUmemAttach_flags"] = {"hipMemAttachFlags_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUmemAttach_flags_enum"] = {"hipMemAttachFlags_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEM_ATTACH_GLOBAL"] = {"hipMemAttachGlobal", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1 // API_Runtime ANALOGUE (#define cudaMemAttachGlobal 0x01) + cuda2hipRename["CU_MEM_ATTACH_HOST"] = {"hipMemAttachHost", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x2 // API_Runtime ANALOGUE (#define cudaMemAttachHost 0x02) + cuda2hipRename["CU_MEM_ATTACH_SINGLE"] = {"hipMemAttachSingle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x4 // API_Runtime ANALOGUE (#define cudaMemAttachSingle 0x04) + + // enum CUmemorytype/CUmemorytype_enum + cuda2hipRename["CUmemorytype"] = {"hipMemType_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no - cudaMemoryType is not an analogue) + cuda2hipRename["CUmemorytype_enum"] = {"hipMemType_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no - cudaMemoryType is not an analogue) + cuda2hipRename["CU_MEMORYTYPE_HOST"] = {"hipMemTypeHost", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_DEVICE"] = {"hipMemTypeDevice", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_ARRAY"] = {"hipMemTypeArray", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_UNIFIED"] = {"hipMemTypeUnified", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (no) + + // enum CUresourcetype + cuda2hipRename["CUresourcetype"] = {"hipResourceType", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceType) + cuda2hipRename["CUresourcetype_enum"] = {"hipResourceType", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceType) + cuda2hipRename["CU_RESOURCE_TYPE_ARRAY"] = {"hipResourceTypeArray", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaResourceTypeArray = 0x00) + cuda2hipRename["CU_RESOURCE_TYPE_MIPMAPPED_ARRAY"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaResourceTypeMipmappedArray = 0x01) + cuda2hipRename["CU_RESOURCE_TYPE_LINEAR"] = {"hipResourceTypeLinear", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaResourceTypeLinear = 0x02) + cuda2hipRename["CU_RESOURCE_TYPE_PITCH2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaResourceTypePitch2D = 0x03) + + // enum CUresourceViewFormat/CUresourceViewFormat_enum + cuda2hipRename["CUresourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceViewFormat) + cuda2hipRename["CUresourceViewFormat_enum"] = {"hipResourceViewFormat", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceViewFormat) + cuda2hipRename["CU_RES_VIEW_FORMAT_NONE"] = {"hipResViewFormatNone", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaResViewFormatNone = 0x00) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X8"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar1 = 0x01) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X8"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar2 = 0x02) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X8"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar4 = 0x03) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X8"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar1 = 0x04) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X8"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x05 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar2 = 0x05) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X8"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x06 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar4 = 0x06) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X16"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x07 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort1 = 0x07) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X16"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort2 = 0x08) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X16"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x09 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort4 = 0x09) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X16"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0a // API_Runtime ANALOGUE (cudaResViewFormatSignedShort1 = 0x0a) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X16"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0b // API_Runtime ANALOGUE (cudaResViewFormatSignedShort2 = 0x0b) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X16"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0c // API_Runtime ANALOGUE (cudaResViewFormatSignedShort4 = 0x0c) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X32"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0d // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt1 = 0x0d) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X32"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0e // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt2 = 0x0e) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X32"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0f // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt4 = 0x0f) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X32"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt1 = 0x10) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X32"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x11 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt2 = 0x11) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X32"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x12 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt4 = 0x12) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_1X16"] = {"hipResViewFormatHalf1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x13 // API_Runtime ANALOGUE (cudaResViewFormatHalf1 = 0x13) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_2X16"] = {"hipResViewFormatHalf2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x14 // API_Runtime ANALOGUE (cudaResViewFormatHalf2 = 0x14) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_4X16"] = {"hipResViewFormatHalf4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x15 // API_Runtime ANALOGUE (cudaResViewFormatHalf4 = 0x15) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_1X32"] = {"hipResViewFormatFloat1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x16 // API_Runtime ANALOGUE (cudaResViewFormatFloat1 = 0x16) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_2X32"] = {"hipResViewFormatFloat2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x17 // API_Runtime ANALOGUE (cudaResViewFormatFloat2 = 0x17) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_4X32"] = {"hipResViewFormatFloat4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x18 // API_Runtime ANALOGUE (cudaResViewFormatFloat4 = 0x18) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x19 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed1 = 0x19) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1a // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed2 = 0x1a) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1b // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed3 = 0x1b) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1c // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed4 = 0x1c) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1d // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed4 = 0x1d) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1e // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed5 = 0x1e) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1f // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed5 = 0x1f) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC6H"] = {"hipResViewFormatUnsignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed6H = 0x20) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x21 // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed6H = 0x21) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x22 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed7 = 0x22) + + + + cuda2hipRename["CUsharedconfig_enum"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUsharedconfig"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; + + cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUctx_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUmod_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUstream_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; // Stream Flags - cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; - cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; + cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; + cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; // Init - cuda2hipRename["cuInit"] = {"hipInit", CONV_DRIVER, API_DRIVER}; + cuda2hipRename["cuInit"] = {"hipInit", CONV_DRIVER, API_DRIVER}; // Driver cuda2hipRename["cuDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_DRIVER}; @@ -346,8 +797,8 @@ struct cuda2hipMap { cuda2hipRename["cuCtxEnablePeerAccess"] = {"hipCtxEnablePeerAccess", CONV_CONTEXT, API_DRIVER}; cuda2hipRename["cuCtxDisablePeerAccess"] = {"hipCtxDisablePeerAccess", CONV_CONTEXT, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuCtxSetLimit"] = {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER}; - // cuda2hipRename["cuCtxGetLimit"] = {"hipCtxGetLimit", CONV_CONTEXT, API_DRIVER}; + cuda2hipRename["cuCtxSetLimit"] = {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuCtxGetLimit"] = {"hipCtxGetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}; // Device cuda2hipRename["cuDeviceGet"] = {"hipGetDevice", CONV_DEV, API_DRIVER}; @@ -356,13 +807,26 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceGetProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceGetPCIBusId"] = {"hipDeviceGetPCIBusId", CONV_DEV, API_DRIVER}; - // unsupported yet by HIP - // cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER}; + cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER}; + cuda2hipRename["cuDeviceTotalMem_v2"] = {"hipDeviceTotalMem", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceComputeCapability"] = {"hipDeviceComputeCapability", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; // Events + // pointer to CUevent_st + cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; + // ToDo: + // cuda2hipRename["CUevent_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; + // Event Flags + cuda2hipRename["CUevent_flags"] = {"hipEventFlags", CONV_EVENT, API_DRIVER, HIP_UNSUPPORTED}; + // ToDo: + // cuda2hipRename["CUevent_flags_enum"] = {"hipEventFlags", CONV_EVENT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_DISABLE_TIMING"] = {"hipEventDisableTiming", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_INTERPROCESS"] = {"hipEventInterprocess", CONV_EVENT, API_DRIVER}; + // Event functions cuda2hipRename["cuEventCreate"] = {"hipEventCreate", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventDestroy_v2"] = {"hipEventDestroy", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}; @@ -376,14 +840,16 @@ struct cuda2hipMap { cuda2hipRename["cuModuleLoad"] = {"hipModuleLoad", CONV_MODULE, API_DRIVER}; cuda2hipRename["cuModuleLoadData"] = {"hipModuleLoadData", CONV_MODULE, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuModuleLoadDataEx"] = {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER}; - // cuda2hipRename["cuModuleLoadFatBinary"] = {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER}; + cuda2hipRename["cuModuleLoadDataEx"] = {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuModuleLoadFatBinary"] = {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuModuleUnload"] = {"hipModuleUnload", CONV_MODULE, API_DRIVER}; cuda2hipRename["cuLaunchKernel"] = {"hipModuleLaunchKernel", CONV_MODULE, API_DRIVER}; // Streams // unsupported yet by HIP - // cuda2hipRename["cuStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_DRIVER}; cuda2hipRename["cuStreamDestroy_v2"] = {"hipStreamDestroy", CONV_STREAM, API_DRIVER}; cuda2hipRename["cuStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_DRIVER}; @@ -405,77 +871,194 @@ struct cuda2hipMap { cuda2hipRename["cuMemcpyHtoDAsync_v2"] = {"hipMemcpyHtoDAsync", CONV_MEM, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuMemsetD8_v2"] = {"hipMemsetD8", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD8Async"] = {"hipMemsetD8Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D8_v2"] = {"hipMemsetD2D8", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D8Async"] = {"hipMemsetD2D8Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD16_v2"] = {"hipMemsetD16", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD16Async"] = {"hipMemsetD16Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D16_v2"] = {"hipMemsetD2D16", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuMemsetD8_v2"] = {"hipMemsetD8", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD8Async"] = {"hipMemsetD8Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D8_v2"] = {"hipMemsetD2D8", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D8Async"] = {"hipMemsetD2D8Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD16_v2"] = {"hipMemsetD16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD16Async"] = {"hipMemsetD16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D16_v2"] = {"hipMemsetD2D16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD32_v2"] = {"hipMemset", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemsetD32Async"] = {"hipMemsetAsync", CONV_MEM, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuMemsetD2D32_v2"] = {"hipMemsetD2D32", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D32Async"] = {"hipMemsetD2D32Async", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuMemsetD2D32_v2"] = {"hipMemsetD2D32", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D32Async"] = {"hipMemsetD2D32Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cuMemGetInfo_v2"] = {"hipMemGetInfo", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemHostRegister_v2"] = {"hipHostRegister", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_DRIVER}; + // Texture Reference Mngmnt + // Texture reference filtering modes + cuda2hipRename["CUfilter_mode"] = {"hipTextureFilterMode", CONV_TEX, API_DRIVER}; // API_Runtime ANALOGUE (cudaTextureFilterMode) + // ToDo: + // cuda2hipRename["CUfilter_mode"] = {"CUfilter_mode_enum", CONV_TEX, API_DRIVER}; // API_Runtime ANALOGUE (cudaTextureFilterMode) + cuda2hipRename["CU_TR_FILTER_MODE_POINT"] = {"hipFilterModePoint", CONV_TEX, API_DRIVER}; // 0 // API_Runtime ANALOGUE (cudaFilterModePoint = 0) + cuda2hipRename["CU_TR_FILTER_MODE_LINEAR"] = {"hipFilterModeLinear", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (cudaFilterModeLinear = 1) + // Profiler // unsupported yet by HIP - // cuda2hipRename["cuProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_DRIVER}; + cuda2hipRename["cuProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_DRIVER}; cuda2hipRename["cuProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_DRIVER}; /////////////////////////////// CUDA RT API /////////////////////////////// - // Error API - cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; + // Data types + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["cudaDataType_t"] = {"hipDataType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDataType"] = {"hipDataType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_16F"] = {"hipR16F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_16F"] = {"hipC16F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32F"] = {"hipR32F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32F"] = {"hipC32F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_64F"] = {"hipR64F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_64F"] = {"hipC64F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_8I"] = {"hipR8I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_8I"] = {"hipC8I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_8U"] = {"hipR8U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_8U"] = {"hipC8U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32I"] = {"hipR32I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32I"] = {"hipC32I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32U"] = {"hipR32U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32U"] = {"hipC32U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; - // Memcpy - cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; - // Memcpy kind - cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDeviceToHost"] = {"hipMemcpyDeviceToHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDeviceToDevice"] = {"hipMemcpyDeviceToDevice", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDefault"] = {"hipMemcpyDefault", CONV_MEM, API_RUNTIME}; + // Library property types + // IMPORTANT: no cuda prefix + // TO_DO: new matcher is needed + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["libraryPropertyType_t"] = {"hipLibraryPropertyType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["libraryPropertyType"] = {"hipLibraryPropertyType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["MAJOR_VERSION"] = {"hipLibraryMajorVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["MINOR_VERSION"] = {"hipLibraryMinorVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["PATCH_LEVEL"] = {"hipLibraryPatchVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + + // defines + cuda2hipRename["cudaMemAttachGlobal"] = {"hipMemAttachGlobal", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_MEM_ATTACH_GLOBAL = 0x1) + cuda2hipRename["cudaMemAttachHost"] = {"hipMemAttachHost", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_MEM_ATTACH_HOST = 0x2) + cuda2hipRename["cudaMemAttachSingle"] = {"hipMemAttachSingle", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_MEM_ATTACH_SINGLE = 0x4) + + cuda2hipRename["cudaOccupancyDefault"] = {"hipOccupancyDefault", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_OCCUPANCY_DEFAULT = 0x0) + cuda2hipRename["cudaOccupancyDisableCachingOverride"] = {"hipOccupancyDisableCachingOverride", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 0x1) + + // Error API + cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; + + // Arrays + cuda2hipRename["cudaArray"] = {"hipArray", CONV_MEM, API_RUNTIME}; + // typedef struct cudaArray *cudaArray_t; + cuda2hipRename["cudaArray_t"] = {"hipArray *", CONV_MEM, API_RUNTIME}; + // typedef const struct cudaArray *cudaArray_const_t; + cuda2hipRename["cudaArray_const_t"] = {"const hipArray *", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // memcpy + // memcpy structs + // unsupported yet by HIP + cuda2hipRename["cudaMemcpy3DParms"] = {"hipMemcpy3DParms", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeerParms"] = {"hipMemcpy3DPeerParms", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // memcpy functions + cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToSymbolAsync"] = {"hipMemcpyToSymbolAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMemcpy2DArrayToArray"] = {"hipMemcpy2DArrayToArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DAsync"] = {"hipMemcpy2DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DFromArray"] = {"hipMemcpy2DFromArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DFromArrayAsync"] = {"hipMemcpy2DFromArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DToArrayAsync"] = {"hipMemcpy2DToArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3D"] = {"hipMemcpy3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DAsync"] = {"hipMemcpy3DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeer"] = {"hipMemcpy3DPeer", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeerAsync"] = {"hipMemcpy3DPeerAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyArrayToArray"] = {"hipMemcpyArrayToArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyFromArrayAsync"] = {"hipMemcpyFromArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyFromSymbolAsync"] = {"hipMemcpyFromSymbolAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // memcpy kind + cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDeviceToHost"] = {"hipMemcpyDeviceToHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDeviceToDevice"] = {"hipMemcpyDeviceToDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDefault"] = {"hipMemcpyDefault", CONV_MEM, API_RUNTIME}; + + // memset + cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMemset2D"] = {"hipMemset2D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset2DAsync"] = {"hipMemset2DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset3D"] = {"hipMemset3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset3DAsync"] = {"hipMemset3DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; // Memory management - cuda2hipRename["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaFree"] = {"hipFree", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaFreeHost"] = {"hipHostFree", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegister"] = {"hipHostRegister", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaArrayGetInfo"] = {"hipArrayGetInfo", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFreeMipmappedArray"] = {"hipFreeMipmappedArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetMipmappedArrayLevel"] = {"hipGetMipmappedArrayLevel", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSymbolAddress"] = {"hipGetSymbolAddress", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSymbolSize"] = {"hipGetSymbolSize", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // malloc + cuda2hipRename["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocArray"] = {"hipMallocArray", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMalloc3D"] = {"hipMalloc3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMalloc3DArray"] = {"hipMalloc3DArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocManaged"] = {"hipMallocManaged", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocMipmappedArray"] = {"hipMallocMipmappedArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocPitch"] = {"hipMallocPitch", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaFree"] = {"hipFree", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaFreeHost"] = {"hipHostFree", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaFreeArray"] = {"hipFreeArray", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegister"] = {"hipHostRegister", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_RUNTIME}; + // hipHostAlloc deprecated - use hipHostMalloc instead + cuda2hipRename["cudaHostAlloc"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; // Memory types - cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; // API_Driver ANALOGUE (no - CUmemorytype is not an analogue) + cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; + + // make memory functions + // unsupported yet by HIP + cuda2hipRename["make_cudaExtent"] = {"make_hipExtent", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["make_cudaPitchedPtr"] = {"make_hipPitchedPtr", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["make_cudaPos"] = {"make_hipPos", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaExtent"] = {"hipExtent", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaPitchedPtr"] = {"hipPitchedPtr", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaPos"] = {"hipPos", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; // Host Malloc Flags - cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocMapped"] = {"hipHostMallocMapped", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocWriteCombined"] = {"hipHostMallocWriteCombined", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocMapped"] = {"hipHostMallocMapped", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocWriteCombined"] = {"hipHostMallocWriteCombined", CONV_MEM, API_RUNTIME}; // Host Register Flags - cuda2hipRename["cudaHostGetFlags"] = {"hipHostGetFlags", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterDefault"] = {"hipHostRegisterDefault", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterPortable"] = {"hipHostRegisterPortable", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterMapped"] = {"hipHostRegisterMapped", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterIoMemory"] = {"hipHostRegisterIoMemory", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostGetFlags"] = {"hipHostGetFlags", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterDefault"] = {"hipHostRegisterDefault", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterPortable"] = {"hipHostRegisterPortable", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterMapped"] = {"hipHostRegisterMapped", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterIoMemory"] = {"hipHostRegisterIoMemory", CONV_MEM, API_RUNTIME}; // Coordinate Indexing and Dimensions cuda2hipRename["threadIdx.x"] = {"hipThreadIdx_x", CONV_COORD_FUNC, API_RUNTIME}; @@ -509,123 +1092,247 @@ struct cuda2hipMap { cuda2hipRename["warpSize"] = {"hipWarpSize", CONV_SPECIAL_FUNC, API_RUNTIME}; // Events - cuda2hipRename["cudaEvent_t"] = {"hipEvent_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaEventCreate"] = {"hipEventCreate", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventCreateWithFlags"] = {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventDestroy"] = {"hipEventDestroy", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventRecord"] = {"hipEventRecord", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventSynchronize"] = {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventQuery"] = {"hipEventQuery", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEvent_t"] = {"hipEvent_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaEventCreate"] = {"hipEventCreate", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventCreateWithFlags"] = {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventDestroy"] = {"hipEventDestroy", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventRecord"] = {"hipEventRecord", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventSynchronize"] = {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventQuery"] = {"hipEventQuery", CONV_EVENT, API_RUNTIME}; // Event Flags - cuda2hipRename["cudaEventDefault"] = {"hipEventDefault", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventBlockingSync"] = {"hipEventBlockingSync", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventDisableTiming"] = {"hipEventDisableTiming", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventInterprocess"] = {"hipEventInterprocess", CONV_EVENT, API_RUNTIME}; - + cuda2hipRename["cudaEventDefault"] = {"hipEventDefault", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventBlockingSync"] = {"hipEventBlockingSync", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventDisableTiming"] = {"hipEventDisableTiming", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventInterprocess"] = {"hipEventInterprocess", CONV_EVENT, API_RUNTIME}; // Streams - cuda2hipRename["cudaStream_t"] = {"hipStream_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamCreateWithFlags"] = {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamDestroy"] = {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamWaitEvent"] = {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamSynchronize"] = {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamGetFlags"] = {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStream_t"] = {"hipStream_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamCreateWithFlags"] = {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaStreamCreateWithPriority"] = {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaStreamDestroy"] = {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamWaitEvent"] = {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamSynchronize"] = {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamGetFlags"] = {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaStreamAttachMemAsync"] = {"hipStreamAttachMemAsync", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaStreamGetPriority"] = {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; + // Stream Flags - cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; // Other synchronization - cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadSynchronize - cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadExit - cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaChooseDevice"] = {"hipChooseDevice", CONV_DEV, API_RUNTIME}; // Attributes - cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; // API_DRIVER ANALOGUE (CUdevice_attribute) + cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; // 1 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1) + cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; // 2 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2) + cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; // 3 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3) + cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; // 4 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4) + cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; // 5 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5) + cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; // 6 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 6) + cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; // 7 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 7) + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; // 8 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8) + cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; // 9 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY =9) + cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; // 10 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10) + cuda2hipRename["cudaDevAttrMaxPitch"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 11 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11) + cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; // 12 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12) + cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; // 13 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13) + cuda2hipRename["cudaDevAttrTextureAlignment"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 14 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14) + // Is not deprecated as CUDA Driver's API analogue CU_DEVICE_ATTRIBUTE_GPU_OVERLAP + cuda2hipRename["cudaDevAttrGpuOverlap"] = {"hipDeviceAttributeGpuOverlap", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 15 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15) + cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; // 16 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16) + cuda2hipRename["cudaDevAttrKernelExecTimeout"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 17 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17) + cuda2hipRename["cudaDevAttrIntegrated"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 18 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_INTEGRATED = 18) + cuda2hipRename["cudaDevAttrCanMapHostMemory"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 19 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19) + cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; // 20 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20) + cuda2hipRename["cudaDevAttrMaxTexture1DWidth"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 21 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21) + cuda2hipRename["cudaDevAttrMaxTexture2DWidth"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 22 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22) + cuda2hipRename["cudaDevAttrMaxTexture2DHeight"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 23 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23) + cuda2hipRename["cudaDevAttrMaxTexture3DWidth"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 24 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24) + cuda2hipRename["cudaDevAttrMaxTexture3DHeight"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 25 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25) + cuda2hipRename["cudaDevAttrMaxTexture3DDepth"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 26 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredWidth"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 27 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH = 27) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredHeight"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 28 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT = 28) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredLayers"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 29 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS = 29) + cuda2hipRename["cudaDevAttrSurfaceAlignment"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 30 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT = 30) + cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; // 31 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31) + cuda2hipRename["cudaDevAttrEccEnabled"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 32 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_ECC_ENABLED = 32) + cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; // 33 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33) + cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; // 34 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34) + cuda2hipRename["cudaDevAttrTccDriver"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 35 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35) + cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; // 36 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36) + cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; // 37 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37) + cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; // 38 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE = 38) + cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; // 39 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39) + cuda2hipRename["cudaDevAttrAsyncEngineCount"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 40 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40) + cuda2hipRename["cudaDevAttrUnifiedAddressing"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 41 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41) + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredWidth"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 42 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42) + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredLayers"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 43 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43) + // 44 - no + cuda2hipRename["cudaDevAttrMaxTexture2DGatherWidth"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 45 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH = 45) + cuda2hipRename["cudaDevAttrMaxTexture2DGatherHeight"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 46 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT = 46) + cuda2hipRename["cudaDevAttrMaxTexture3DWidthAlt"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 47 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE = 47) + cuda2hipRename["cudaDevAttrMaxTexture3DHeightAlt"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 48 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE = 48) + cuda2hipRename["cudaDevAttrMaxTexture3DDepthAlt"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 49 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE = 49) + cuda2hipRename["cudaDevAttrPciDomainId"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 50 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID = 50) + cuda2hipRename["cudaDevAttrTexturePitchAlignment"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 51 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51) + cuda2hipRename["cudaDevAttrMaxTextureCubemapWidth"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 52 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH = 52) + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredWidth"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 53 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH = 53) + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredLayers"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 54 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS = 54) + cuda2hipRename["cudaDevAttrMaxSurface1DWidth"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 55 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH = 55) + cuda2hipRename["cudaDevAttrMaxSurface2DWidth"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 56 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH = 56) + cuda2hipRename["cudaDevAttrMaxSurface2DHeight"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 57 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT = 57) + cuda2hipRename["cudaDevAttrMaxSurface3DWidth"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 58 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH = 58) + cuda2hipRename["cudaDevAttrMaxSurface3DHeight"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 59 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT = 59) + cuda2hipRename["cudaDevAttrMaxSurface3DDepth"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 60 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH = 60) + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredWidth"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 61 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH = 61) + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredLayers"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 62 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS = 62) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredWidth"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 63 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH = 63) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredHeight"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 64 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT = 64) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredLayers"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 65 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS = 65) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 66 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH = 66) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 67 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH = 67) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredLayers"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 68 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS = 68) + cuda2hipRename["cudaDevAttrMaxTexture1DLinearWidth"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 69 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH = 69) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearWidth"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 70 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH = 70) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearHeight"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 71 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT = 71) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearPitch"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 72 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH = 72) + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 73 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH = 73) + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedHeight"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 74 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT = 74) + cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; // 75 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75) + cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; // 76 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76) + cuda2hipRename["cudaDevAttrMaxTexture1DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 77 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH = 77) + cuda2hipRename["cudaDevAttrStreamPrioritiesSupported"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 78 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED = 78) + cuda2hipRename["cudaDevAttrGlobalL1CacheSupported"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 79 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED = 79) + cuda2hipRename["cudaDevAttrLocalL1CacheSupported"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 80 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED = 80) + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; // 81 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR = 81) + cuda2hipRename["cudaDevAttrMaxRegistersPerMultiprocessor"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 82 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR = 82) + cuda2hipRename["cudaDevAttrManagedMemory"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 83 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83) + cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; // 84 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84) + cuda2hipRename["cudaDevAttrMultiGpuBoardGroupID"] = {"hipDeviceAttributeMultiGpuBoardGroupID", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 85 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85) + + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["cudaDevAttrHostNativeAtomicSupported"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrSingleToDoublePrecisionPerfRatio"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrPageableMemoryAccess"] = {"hipDeviceAttributePageableMemoryAccess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrConcurrentManagedAccess"] = {"hipDeviceAttributeConcurrentManagedAccess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrComputePreemptionSupported"] = {"hipDeviceAttributeComputePreemptionSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrCanUseHostPointerForRegisteredMem"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Pointer Attributes - cuda2hipRename["cudaPointerAttributes"] = {"hipPointerAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaPointerGetAttributes"] = {"hipPointerGetAttributes", CONV_MEM, API_RUNTIME}; + // struct cudaPointerAttributes + cuda2hipRename["cudaPointerAttributes"] = {"hipPointerAttribute_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaPointerGetAttributes"] = {"hipPointerGetAttributes", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostGetDevicePointer"] = {"hipHostGetDevicePointer", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostGetDevicePointer"] = {"hipHostGetDevicePointer", CONV_MEM, API_RUNTIME}; // Device - cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetPCIBusId"] = {"hipDeviceGetPCIBusId", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceGetStreamPriorityRange"] = {"hipDeviceGetStreamPriorityRange", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetValidDevices"] = {"hipSetValidDevices", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + + // Compute mode + cuda2hipRename["cudaComputeMode"] = {"hipComputeMode", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // API_DRIVER ANALOGUE (CUcomputemode) + cuda2hipRename["cudaComputeModeDefault"] = {"hipComputeModeDefault", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["cudaComputeModeExclusive"] = {"hipComputeModeExclusive", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["cudaComputeModeProhibited"] = {"hipComputeModeProhibited", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["cudaComputeModeExclusiveProcess"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 3 // Device Flags + // unsupported yet by HIP + cuda2hipRename["cudaGetDeviceFlags"] = {"hipGetDeviceFlags", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaSetDeviceFlags"] = {"hipSetDeviceFlags", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleAuto"] = {"hipDeviceScheduleAuto", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleSpin"] = {"hipDeviceScheduleSpin", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleYield"] = {"hipDeviceScheduleYield", CONV_DEV, API_RUNTIME}; // deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync - cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceBlockingSync", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceMapHost"] = {"hipDeviceMapHost", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaDeviceLmemResizeToMax"] = {"hipDeviceLmemResizeToMax", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaDeviceMask"] = {"hipDeviceMask", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceLmemResizeToMax"] = {"hipDeviceLmemResizeToMax", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceMask"] = {"hipDeviceMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Cache config - cuda2hipRename["cudaDeviceSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaDeviceSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated - cuda2hipRename["cudaThreadSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaThreadSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated - cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCache"] = {"hipFuncCache", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; + + // Execution control + // CUDA function cache configurations + cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; // API_Driver ANALOGUE (CUfunc_cache) + cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; // 0 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_NONE = 0x00) + cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; // 1 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_SHARED = 0x01) + cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; // 2 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_L1 = 0x02) + cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; // 3 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_EQUAL = 0x03) + + // Execution control functions + // unsupported yet by HIP + cuda2hipRename["cudaFuncAttributes"] = {"hipFuncAttributes", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncGetAttributes"] = {"hipFuncGetAttributes", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncSetSharedMemConfig"] = {"hipFuncSetSharedMemConfig", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetParameterBuffer"] = {"hipGetParameterBuffer", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForDevice"] = {"hipSetDoubleForDevice", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForHost"] = {"hipSetDoubleForHost", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + + // Execution Control [deprecated since 7.0] + // unsupported yet by HIP + cuda2hipRename["cudaConfigureCall"] = {"hipConfigureCall", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLaunch"] = {"hipLaunch", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetupArgument"] = {"hipSetupArgument", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; // Driver/Runtime cuda2hipRename["cudaDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + + // Occupancy + cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER}; + // unsupported yet by HIP + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER}; + // unsupported yet by HIP + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMem"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMem", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; // Peer2Peer - cuda2hipRename["cudaDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceDisablePeerAccess"] = {"hipDeviceDisablePeerAccess", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceDisablePeerAccess"] = {"hipDeviceDisablePeerAccess", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; + + // #define cudaIpcMemLazyEnablePeerAccess 0x01 + cuda2hipRename["cudaIpcMemLazyEnablePeerAccess"] = {"hipIpcMemLazyEnablePeerAccess", CONV_TYPE, API_RUNTIME}; // 0x01 // API_Driver ANALOGUE (CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 0x1) // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -634,39 +1341,220 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetSharedMemConfig"] = {"hipDeviceGetSharedMemConfig", CONV_DEV, API_RUNTIME}; // translate deprecated cuda2hipRename["cudaThreadGetSharedMemConfig"] = {"hipDeviceGetSharedMemConfig", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaSharedMemConfig"] = {"hipSharedMemConfig", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaSharedMemBankSizeDefault"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaSharedMemBankSizeFourByte"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaSharedMemBankSizeEightByte"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_RUNTIME}; // Limits - cuda2hipRename["cudaLimit"] = {"hipLimit_t", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME}; - // unsupported yet - cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaLimit"] = {"hipLimit_t", CONV_TYPE, API_RUNTIME}; // API_Driver ANALOGUE (CUlimit) + cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_LIMIT_STACK_SIZE = 0x00) + cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_LIMIT_PRINTF_FIFO_SIZE = 0x01) + cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_TYPE, API_RUNTIME}; // 0x02 // API_Driver ANALOGUE (CU_LIMIT_MALLOC_HEAP_SIZE = 0x02) + cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitDevRuntimeSyncDepth", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 0x03) + cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitDevRuntimePendingLaunchCount", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 0x04) + cuda2hipRename["cudaDeviceGetLimit"] = {"hipDeviceGetLimit", CONV_DEV, API_RUNTIME}; // Profiler - // unsupported yet - //cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; - // Channel descriptor - cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; + cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; + + // unsupported yet by HIP + cuda2hipRename["cudaOutputMode"] = {"hipOutputMode", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaKeyValuePair"] = {"hipKeyValuePair", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaCSV"] = {"hipCSV", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + + // Texture Reference Management + // enums + cuda2hipRename["cudaTextureReadMode"] = {"hipTextureReadMode", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaReadModeNormalizedFloat"] = {"hipReadModeNormalizedFloat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaTextureFilterMode"] = {"hipTextureFilterMode", CONV_TEX, API_RUNTIME}; // API_DRIVER ANALOGUE (CUfilter_mode) + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; // 0 // API_DRIVER ANALOGUE (CU_TR_FILTER_MODE_POINT = 0) + cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_DRIVER ANALOGUE (CU_TR_FILTER_MODE_POINT = 1) + + cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaBindTexture2D"] = {"hipBindTexture2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindTextureToArray"] = {"hipBindTextureToArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindTextureToMipmappedArray"] = {"hipBindTextureToMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureAlignmentOffset"] = {"hipGetTextureAlignmentOffset", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureReference"] = {"hipGetTextureReference", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // Channel + cuda2hipRename["cudaChannelFormatKind"] = {"hipChannelFormatKind", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindSigned"] = {"hipChannelFormatKindSigned", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindUnsigned"] = {"hipChannelFormatKindUnsigned", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindFloat"] = {"hipChannelFormatKindFloat", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindNone"] = {"hipChannelFormatKindNone", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaGetChannelDesc"] = {"hipGetChannelDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // Texture Object Management + // structs + // unsupported yet by HIP + cuda2hipRename["cudaResourceDesc"] = {"hipResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceViewDesc"] = {"hipResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaTextureDesc"] = {"hipTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // enums + // enum cudaResourceType + cuda2hipRename["cudaResourceType"] = {"hipResourceType", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUresourcetype) + cuda2hipRename["cudaResourceTypeArray"] = {"hipResourceTypeArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_ARRAY = 0x00) + cuda2hipRename["cudaResourceTypeMipmappedArray"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01) + cuda2hipRename["cudaResourceTypeLinear"] = {"hipResourceTypeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_LINEAR = 0x02) + cuda2hipRename["cudaResourceTypePitch2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_PITCH2D = 0x03) + + + cuda2hipRename["cudaResourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUresourceViewFormat) + cuda2hipRename["cudaResViewFormatNone"] = {"hipResViewFormatNone", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_NONE = 0x00) + cuda2hipRename["cudaResViewFormatUnsignedChar1"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X8 = 0x01) + cuda2hipRename["cudaResViewFormatUnsignedChar2"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X8 = 0x02) + cuda2hipRename["cudaResViewFormatUnsignedChar4"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X8 = 0x03) + cuda2hipRename["cudaResViewFormatSignedChar1"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X8 = 0x04) + cuda2hipRename["cudaResViewFormatSignedChar2"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x05 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X8 = 0x05) + cuda2hipRename["cudaResViewFormatSignedChar4"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x06 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X8 = 0x06) + cuda2hipRename["cudaResViewFormatUnsignedShort1"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x07 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X16 = 0x07) + cuda2hipRename["cudaResViewFormatUnsignedShort2"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x08 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X16 = 0x08) + cuda2hipRename["cudaResViewFormatUnsignedShort4"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x09 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X16 = 0x09) + cuda2hipRename["cudaResViewFormatSignedShort1"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0a // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X16 = 0x0a) + cuda2hipRename["cudaResViewFormatSignedShort2"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0b // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X16 = 0x0b) + cuda2hipRename["cudaResViewFormatSignedShort4"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0c // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X16 = 0x0c) + cuda2hipRename["cudaResViewFormatUnsignedInt1"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0d // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X32 = 0x0d) + cuda2hipRename["cudaResViewFormatUnsignedInt2"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0e // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X32 = 0x0e) + cuda2hipRename["cudaResViewFormatUnsignedInt4"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0f // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X32 = 0x0f) + cuda2hipRename["cudaResViewFormatSignedInt1"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x10 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X32 = 0x10) + cuda2hipRename["cudaResViewFormatSignedInt2"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x11 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X32 = 0x11) + cuda2hipRename["cudaResViewFormatSignedInt4"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x12 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X32 = 0x12) + cuda2hipRename["cudaResViewFormatHalf1"] = {"hipResViewFormatHalf1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x13 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13) + cuda2hipRename["cudaResViewFormatHalf2"] = {"hipResViewFormatHalf2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x14 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14) + cuda2hipRename["cudaResViewFormatHalf4"] = {"hipResViewFormatHalf4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x15 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15) + cuda2hipRename["cudaResViewFormatFloat1"] = {"hipResViewFormatFloat1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x16 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16) + cuda2hipRename["cudaResViewFormatFloat2"] = {"hipResViewFormatFloat2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x17 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17) + cuda2hipRename["cudaResViewFormatFloat4"] = {"hipResViewFormatFloat4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x18 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x19 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1a // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1b // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1c // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1d // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1e // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1f // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed6H"] = {"hipResViewFormatUnsignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x21 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x22 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22) + + cuda2hipRename["cudaTextureAddressMode"] = {"hipTextureAddressMode", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeWrap"] = {"hipAddressModeWrap", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeClamp"] = {"hipAddressModeClamp", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeMirror"] = {"hipAddressModeMirror", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeBorder"] = {"hipAddressModeBorder", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // functions + cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceDesc"] = {"hipGetTextureObjectResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceViewDesc"] = {"hipGetTextureObjectResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectTextureDesc"] = {"hipGetTextureObjectTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // Surface Reference Management + // unsupported yet by HIP + cuda2hipRename["cudaBindSurfaceToArray"] = {"hipBindSurfaceToArray", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceReference"] = {"hipGetSurfaceReference", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaSurfaceBoundaryMode"] = {"hipSurfaceBoundaryMode", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeZero"] = {"hipBoundaryModeZero", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeClamp"] = {"hipBoundaryModeClamp", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeTrap"] = {"hipBoundaryModeTrap", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaSurfaceFormatMode"] = {"hipSurfaceFormatMode", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFormatModeForced"] = {"hipFormatModeForced", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFormatModeAuto"] = {"hipFormatModeAuto", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Surface Object Management + // unsupported yet by HIP + cuda2hipRename["cudaCreateSurfaceObject"] = {"hipCreateSurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroySurfaceObject"] = {"hipDestroySurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceObjectResourceDesc"] = {"hipGetSurfaceObjectResourceDesc", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Inter-Process Communications (IPC) + // IPC types + cuda2hipRename["cudaIpcEventHandle_t"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcEventHandle_st"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_t"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_st"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + + // IPC functions + cuda2hipRename["cudaIpcCloseMemHandle"] = {"hipIpcCloseMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetEventHandle"] = {"hipIpcGetEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetMemHandle"] = {"hipIpcGetMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenEventHandle"] = {"hipIpcOpenEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenMemHandle"] = {"hipIpcOpenMemHandle", CONV_DEV, API_RUNTIME}; + + // OpenGL Interoperability + // unsupported yet by HIP + cuda2hipRename["cudaGLGetDevices"] = {"hipGLGetDevices", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterBuffer"] = {"hipGraphicsGLRegisterBuffer", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterImage"] = {"hipGraphicsGLRegisterImage", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaWGLGetDevice"] = {"hipWGLGetDevice", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + + // Graphics Interoperability + // unsupported yet by HIP + cuda2hipRename["cudaGraphicsMapResources"] = {"hipGraphicsMapResources", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceGetMappedMipmappedArray"] = {"hipGraphicsResourceGetMappedMipmappedArray", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceGetMappedPointer"] = {"hipGraphicsResourceGetMappedPointer", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceSetMapFlags"] = {"hipGraphicsResourceSetMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsSubResourceGetMappedArray"] = {"hipGraphicsSubResourceGetMappedArray", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsUnmapResources"] = {"hipGraphicsUnmapResources", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsUnregisterResource"] = {"hipGraphicsUnregisterResource", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaGraphicsCubeFace"] = {"hipGraphicsCubeFace", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveX"] = {"hipGraphicsCubeFacePositiveX", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeX"] = {"hipGraphicsCubeFaceNegativeX", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveY"] = {"hipGraphicsCubeFacePositiveY", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeY"] = {"hipGraphicsCubeFaceNegativeY", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveZ"] = {"hipGraphicsCubeFacePositiveZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeZ"] = {"hipGraphicsCubeFaceNegativeZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + + // enum cudaGraphicsMapFlags + cuda2hipRename["cudaGraphicsMapFlags"] = {"hipGraphicsMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUgraphicsMapResourceFlags) + cuda2hipRename["cudaGraphicsMapFlagsNone"] = {"hipGraphicsMapFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 0 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00) + cuda2hipRename["cudaGraphicsMapFlagsReadOnly"] = {"hipGraphicsMapFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01) + cuda2hipRename["cudaGraphicsMapFlagsWriteDiscard"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 2 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02) + + // enum cudaGraphicsRegisterFlags + cuda2hipRename["cudaGraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUgraphicsRegisterFlags) + cuda2hipRename["cudaGraphicsRegisterFlagsNone"] = {"hipGraphicsRegisterFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 0 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00) + cuda2hipRename["cudaGraphicsRegisterFlagsReadOnly"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01) + cuda2hipRename["cudaGraphicsRegisterFlagsWriteDiscard"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 2 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02) + cuda2hipRename["cudaGraphicsRegisterFlagsSurfaceLoadStore"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 4 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST = 0x04) + cuda2hipRename["cudaGraphicsRegisterFlagsTextureGather"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 8 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 0x08) //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; + // TODO: dereferencing: typedef struct cublasContext *cublasHandle_t; + cuda2hipRename["cublasContext"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; + // Blas management functions + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasInit"] = {"hipblasInit", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasShutdown"] = {"hipblasShutdown", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetVersion"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetError"] = {"hipblasGetError", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasAlloc"] = {"hipblasAlloc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasFree"] = {"hipblasFree", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetKernelStream"] = {"hipblasSetKernelStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetAtomicsMode"] = {"hipblasGetAtomicsMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetAtomicsMode"] = {"hipblasSetAtomicsMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas operations cuda2hipRename["cublasOperation_t"] = {"hipblasOperation_t", CONV_TYPE, API_BLAS}; cuda2hipRename["CUBLAS_OP_N"] = {"HIPBLAS_OP_N", CONV_NUMERIC_LITERAL, API_BLAS}; @@ -684,647 +1572,735 @@ struct cuda2hipMap { cuda2hipRename["CUBLAS_STATUS_NOT_SUPPORTED"] = {"HIPBLAS_STATUS_INTERNAL_ERROR", CONV_NUMERIC_LITERAL, API_BLAS}; // Blas Fill Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasFillMode_t"] = {"hipblasFillMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_FILL_MODE_LOWER"] = {"HIPBLAS_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_FILL_MODE_UPPER"] = {"HIPBLAS_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasFillMode_t"] = {"hipblasFillMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_FILL_MODE_LOWER"] = {"HIPBLAS_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_FILL_MODE_UPPER"] = {"HIPBLAS_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Diag Types // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasDiagType_t"] = {"hipblasDiagType_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_DIAG_NON_UNIT"] = {"HIPBLAS_DIAG_NON_UNIT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DIAG_UNIT"] = {"HIPBLAS_DIAG_UNIT", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasDiagType_t"] = {"hipblasDiagType_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DIAG_NON_UNIT"] = {"HIPBLAS_DIAG_NON_UNIT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DIAG_UNIT"] = {"HIPBLAS_DIAG_UNIT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Side Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasSideMode_t"] = {"hipblasSideMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_SIDE_LEFT"] = {"HIPBLAS_SIDE_LEFT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_SIDE_RIGHT"] = {"HIPBLAS_SIDE_RIGHT", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasSideMode_t"] = {"hipblasSideMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_SIDE_LEFT"] = {"HIPBLAS_SIDE_LEFT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_SIDE_RIGHT"] = {"HIPBLAS_SIDE_RIGHT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Pointer Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasPointerMode_t"] = {"hipblasPointerMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_POINTER_MODE_HOST"] = {"HIPBLAS_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_POINTER_MODE_DEVICE"] = {"HIPBLAS_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasPointerMode_t"] = {"hipblasPointerMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_POINTER_MODE_HOST"] = {"HIPBLAS_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_POINTER_MODE_DEVICE"] = {"HIPBLAS_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Atomics Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasAtomicsMode_t"] = {"hipblasAtomicsMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_ATOMICS_NOT_ALLOWED"] = {"HIPBLAS_ATOMICS_NOT_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_ATOMICS_ALLOWED"] = {"HIPBLAS_ATOMICS_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasAtomicsMode_t"] = {"hipblasAtomicsMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_ATOMICS_NOT_ALLOWED"] = {"HIPBLAS_ATOMICS_NOT_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_ATOMICS_ALLOWED"] = {"HIPBLAS_ATOMICS_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Data Type // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasDataType_t"] = {"hipblasDataType_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_FLOAT"] = {"HIPBLAS_DATA_FLOAT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_DOUBLE"] = {"HIPBLAS_DATA_DOUBLE", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_HALF"] = {"HIPBLAS_DATA_HALF", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_INT8"] = {"HIPBLAS_DATA_INT8", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasDataType_t"] = {"hipblasDataType_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_FLOAT"] = {"HIPBLAS_DATA_FLOAT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_DOUBLE"] = {"HIPBLAS_DATA_DOUBLE", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_HALF"] = {"HIPBLAS_DATA_HALF", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_INT8"] = {"HIPBLAS_DATA_INT8", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas1 (v1) Routines - cuda2hipRename["cublasCreate"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDestroy"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCreate"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDestroy"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasSetVector"] = {"hipblasSetVector", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasGetVector"] = {"hipblasGetVector", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasSetMatrix"] = {"hipblasSetMatrix", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasGetMatrix"] = {"hipblasGetMatrix", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSetVector"] = {"hipblasSetVector", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetVector"] = {"hipblasGetVector", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSetMatrix"] = {"hipblasSetMatrix", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetMatrix"] = {"hipblasGetMatrix", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasGetMatrixAsync"] = {"hipblasGetMatrixAsync", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetMatrixAsync"] = {"hipblasSetMatrixAsync", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetMatrixAsync"] = {"hipblasGetMatrixAsync", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetMatrixAsync"] = {"hipblasSetMatrixAsync", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // NRM2 - //cuda2hipRename["cublasSnrm2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDnrm2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScnrm2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDznrm2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSnrm2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDnrm2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasScnrm2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDznrm2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DOT - cuda2hipRename["cublasSdot"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdot"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSdotBatched"] = {"hipblasSdotBatched",CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDdot"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdotBatched"] = {"hipblasSdotBatched",CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdot"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDdotBatched"] = {"hipblasDdotBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotu"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotc"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotu"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotc"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdotBatched"] = {"hipblasDdotBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCdotu"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdotc"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotu"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotc"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SCAL - cuda2hipRename["cublasSscal"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscal"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSscalBatched"] = {"hipblasSscalBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDscal"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscalBatched"] = {"hipblasSscalBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscal"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDscalBatched"] = {"hipblasDscalBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCscal"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsscal"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZscal"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdscal"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscalBatched"] = {"hipblasDscalBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCscal"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsscal"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZscal"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdscal"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AXPY - cuda2hipRename["cublasSaxpy"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpy"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSaxpyBatched"] = {"hipblasSaxpyBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDaxpy"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCaxpy"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZaxpy"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpyBatched"] = {"hipblasSaxpyBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDaxpy"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCaxpy"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZaxpy"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // COPY - cuda2hipRename["cublasScopy"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopy"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasScopyBatched"] = {"hipblasScopyBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDcopy"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopyBatched"] = {"hipblasScopyBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopy"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDcopyBatched"] = {"hipblasDcopyBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCcopy"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZcopy"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopyBatched"] = {"hipblasDcopyBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCcopy"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZcopy"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SWAP - //cuda2hipRename["cublasSswap"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDswap"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCswap"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZswap"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSswap"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDswap"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCswap"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZswap"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMAX - //cuda2hipRename["cublasIsamax"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamax"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamax"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamax"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamax"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamax"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamax"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamax"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMIN - //cuda2hipRename["cublasIsamin"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamin"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamin"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamin"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamin"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamin"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamin"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamin"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ASUM - cuda2hipRename["cublasSasum"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasum"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSasumBatched"] = {"hipblasSasumBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDasum"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasumBatched"] = {"hipblasSasumBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasum"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDasumBatched"] = {"hipblasDasumBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScasum"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDzasum"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasumBatched"] = {"hipblasDasumBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasScasum"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDzasum"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROT - //cuda2hipRename["cublasSrot"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrot"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrot"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsrot"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrot"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdrot"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrot"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrot"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrot"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsrot"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrot"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdrot"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTG - //cuda2hipRename["cublasSrotg"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotg"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrotg"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrotg"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotg"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotg"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrotg"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrotg"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTM - //cuda2hipRename["cublasSrotm"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotm"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotm"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotm"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTMG - //cuda2hipRename["cublasSrotmg"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotmg"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotmg"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotmg"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GEMV - cuda2hipRename["cublasSgemv"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemv"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSgemvBatched"] = {"hipblasSgemvBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemv"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgemv"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemv"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemvBatched"] = {"hipblasSgemvBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemv"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemv"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemv"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GBMV - //cuda2hipRename["cublasSgbmv"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgbmv"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgbmv"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgbmv"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgbmv"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgbmv"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgbmv"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgbmv"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMV - //cuda2hipRename["cublasStrmv"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmv"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmv"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmv"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmv"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmv"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmv"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmv"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBMV - //cuda2hipRename["cublasStbmv"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbmv"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbmv"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbmv"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbmv"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbmv"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbmv"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbmv"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPMV - //cuda2hipRename["cublasStpmv"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpmv"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpmv"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpmv"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpmv"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpmv"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpmv"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpmv"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSV - //cuda2hipRename["cublasStrsv"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsv"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsv"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsv"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsv"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsv"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsv"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsv"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPSV - //cuda2hipRename["cublasStpsv"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpsv"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpsv"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpsv"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpsv"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpsv"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpsv"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpsv"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBSV - //cuda2hipRename["cublasStbsv"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbsv"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbsv"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbsv"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbsv"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbsv"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbsv"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbsv"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMV/HEMV - //cuda2hipRename["cublasSsymv"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymv"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymv"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymv"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChemv"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemv"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymv"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymv"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymv"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymv"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChemv"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemv"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SBMV/HBMV - //cuda2hipRename["cublasSsbmv"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsbmv"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChbmv"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhbmv"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsbmv"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsbmv"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChbmv"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhbmv"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPMV/HPMV - //cuda2hipRename["cublasSspmv"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspmv"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpmv"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpmv"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspmv"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspmv"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpmv"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpmv"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GER - cuda2hipRename["cublasSger"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDger"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgeru"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgerc"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgeru"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgerc"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSger"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDger"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeru"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgerc"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeru"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgerc"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR/HER - //cuda2hipRename["cublasSsyr"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR/HPR - //cuda2hipRename["cublasSspr"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2/HER2 - //cuda2hipRename["cublasSsyr2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR2/HPR2 - //cuda2hipRename["cublasSspr2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas3 (v1) Routines // GEMM - cuda2hipRename["cublasSgemm"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasCgemm"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemm"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + + cuda2hipRename["cublasCgemm"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // BATCH GEMM - cuda2hipRename["cublasSgemmBatched"] = {"hipblasSgemmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasCgemmBatched"] = {"hipblasCgemmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemmBatched"] = {"hipblasSgemmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + + cuda2hipRename["cublasCgemmBatched"] = {"hipblasCgemmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRK - //cuda2hipRename["cublasSsyrk"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyrk"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyrk"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyrk"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrk"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrk"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrk"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrk"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERK - //cuda2hipRename["cublasCherk"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZherk"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherk"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherk"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2K - //cuda2hipRename["cublasSsyr2k"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2k"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2k"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2k"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2k"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2k"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2k"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2k"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRKX - eXtended SYRK - // cublasSsyrkx - // cublasDsyrkx - // cublasCsyrkx - // cublasZsyrkx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrkx"] = {"hipblasSsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrkx"] = {"hipblasDsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrkx"] = {"hipblasCsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrkx"] = {"hipblasZsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + // HER2K - //cuda2hipRename["cublasCher2k"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2k"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCher2k"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2k"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERKX - eXtended HERK - // cublasCherkx - // cublasZherkx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherkx"] = {"hipblasCherkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherkx"] = {"hipblasZherkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMM - //cuda2hipRename["cublasSsymm"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymm"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymm"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymm"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymm"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymm"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymm"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymm"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HEMM - //cuda2hipRename["cublasChemm"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemm"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasChemm"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemm"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - //cuda2hipRename["cublasStrsm"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsm"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsm"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsm"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsm"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsm"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsm"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsm"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - Batched Triangular Solver - //cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMM - //cuda2hipRename["cublasStrmm"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmm"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmm"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmm"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS}; - - - // TO SUPPORT OR NOT? (cublas_api.h) - // ------------------------ CUBLAS BLAS - like extension + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmm"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmm"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmm"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmm"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + // ------------------------ CUBLAS BLAS - like extension (cublas_api.h) // GEAM - // cublasSgeam - // cublasDgeam - // cublasCgeam - // cublasZgeam + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgeam"] = {"hipblasSgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgeam"] = {"hipblasDgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeam"] = {"hipblasCgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeam"] = {"hipblasZgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GETRF - Batched LU - // cublasSgetrfBatched - // cublasDgetrfBatched - // cublasCgetrfBatched - // cublasZgetrfBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetrfBatched"] = {"hipblasSgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetrfBatched"] = {"hipblasDgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetrfBatched"] = {"hipblasCgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetrfBatched"] = {"hipblasZgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batched inversion based on LU factorization from getrf - // cublasSgetriBatched - // cublasDgetriBatched - // cublasCgetriBatched - // cublasZgetriBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetriBatched"] = {"hipblasSgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetriBatched"] = {"hipblasDgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetriBatched"] = {"hipblasCgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetriBatched"] = {"hipblasZgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batched solver based on LU factorization from getrf - // cublasSgetrsBatched - // cublasDgetrsBatched - // cublasCgetrsBatched - // cublasZgetrsBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetrsBatched"] = {"hipblasSgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetrsBatched"] = {"hipblasDgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetrsBatched"] = {"hipblasCgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetrsBatched"] = {"hipblasZgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - Batched Triangular Solver - // cublasStrsmBatched - // cublasDtrsmBatched - // cublasCtrsmBatched - // cublasZtrsmBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // MATINV - Batched - // cublasSmatinvBatched - // cublasDmatinvBatched - // cublasCmatinvBatched - // cublasZmatinvBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSmatinvBatched"] = {"hipblasSmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDmatinvBatched"] = {"hipblasDmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCmatinvBatched"] = {"hipblasCmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZmatinvBatched"] = {"hipblasZmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batch QR Factorization - // cublasSgeqrfBatched - // cublasDgeqrfBatched - // cublasCgeqrfBatched - // cublasZgeqrfBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgeqrfBatched"] = {"hipblasSgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgeqrfBatched"] = {"hipblasDgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeqrfBatched"] = {"hipblasCgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeqrfBatched"] = {"hipblasZgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Least Square Min only m >= n and Non-transpose supported - // cublasSgelsBatched - // cublasDgelsBatched - // cublasCgelsBatched - // cublasZgelsBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgelsBatched"] = {"hipblasSgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgelsBatched"] = {"hipblasDgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgelsBatched"] = {"hipblasCgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgelsBatched"] = {"hipblasZgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DGMM - // cublasSdgmm - // cublasDdgmm - // cublasCdgmm - // cublasZdgmm + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSdgmm"] = {"hipblasSdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDdgmm"] = {"hipblasDdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdgmm"] = {"hipblasCdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdgmm"] = {"hipblasZdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPTTR - Triangular Pack format to Triangular format - // cublasStpttr - // cublasDtpttr - // cublasCtpttr - // cublasZtpttr + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpttr"] = {"hipblasStpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpttr"] = {"hipblasDtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpttr"] = {"hipblasCtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpttr"] = {"hipblasZtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRTTP - Triangular format to Triangular Pack format - // cublasStrttp - // cublasDtrttp - // cublasCtrttp - // cublasZtrttp + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrttp"] = {"hipblasStrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrttp"] = {"hipblasDtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrttp"] = {"hipblasCtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrttp"] = {"hipblasZtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas2 (v2) Routines - cuda2hipRename["cublasCreate_v2"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDestroy_v2"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCreate_v2"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDestroy_v2"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasGetVersion_v2"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetStream_v2"] = {"hipblasSetStream", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasGetStream_v2"] = {"hipblasGetStream", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasGetPointerMode_v2"] = {"hipblasGetPointerMode", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetPointerMode_v2"] = {"hipblasSetPointerMode", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetVersion_v2"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetStream_v2"] = {"hipblasSetStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetStream_v2"] = {"hipblasGetStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetPointerMode_v2"] = {"hipblasGetPointerMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetPointerMode_v2"] = {"hipblasSetPointerMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GEMV - cuda2hipRename["cublasSgemv_v2"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemv_v2"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgemv_v2"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemv_v2"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemv_v2"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemv_v2"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemv_v2"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemv_v2"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GBMV - //cuda2hipRename["cublasSgbmv_v2"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgbmv_v2"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgbmv_v2"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgbmv_v2"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgbmv_v2"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgbmv_v2"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgbmv_v2"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgbmv_v2"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMV - //cuda2hipRename["cublasStrmv_v2"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmv_v2"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmv_v2"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmv_v2"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmv_v2"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmv_v2"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmv_v2"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmv_v2"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBMV - //cuda2hipRename["cublasStbmv_v2"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbmv_v2"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbmv_v2"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbmv_v2"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbmv_v2"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbmv_v2"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbmv_v2"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbmv_v2"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPMV - //cuda2hipRename["cublasStpmv_v2"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpmv_v2"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpmv_v2"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpmv_v2"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpmv_v2"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpmv_v2"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpmv_v2"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpmv_v2"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSV - //cuda2hipRename["cublasStrsv_v2"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsv_v2"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsv_v2"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsv_v2"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsv_v2"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsv_v2"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsv_v2"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsv_v2"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPSV - //cuda2hipRename["cublasStpsv_v2"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpsv_v2"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpsv_v2"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpsv_v2"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpsv_v2"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpsv_v2"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpsv_v2"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpsv_v2"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBSV - //cuda2hipRename["cublasStbsv_v2"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbsv_v2"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbsv_v2"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbsv_v2"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbsv_v2"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbsv_v2"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbsv_v2"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbsv_v2"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMV/HEMV - //cuda2hipRename["cublasSsymv_v2"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymv_v2"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymv_v2"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymv_v2"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChemv_v2"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemv_v2"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymv_v2"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymv_v2"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymv_v2"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymv_v2"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChemv_v2"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemv_v2"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SBMV/HBMV - //cuda2hipRename["cublasSsbmv_v2"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsbmv_v2"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChbmv_v2"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhbmv_v2"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsbmv_v2"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsbmv_v2"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChbmv_v2"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhbmv_v2"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPMV/HPMV - //cuda2hipRename["cublasSspmv_v2"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspmv_v2"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpmv_v2"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpmv_v2"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspmv_v2"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspmv_v2"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpmv_v2"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpmv_v2"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GER - cuda2hipRename["cublasSger_v2"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDger_v2"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgeru_v2"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgerc_v2"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgeru_v2"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgerc_v2"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSger_v2"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDger_v2"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeru_v2"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgerc_v2"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeru_v2"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgerc_v2"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR/HER - //cuda2hipRename["cublasSsyr_v2"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr_v2"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr_v2"] = {"hipblasCsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr_v2"] = {"hipblasZsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher_v2"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher_v2"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr_v2"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr_v2"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr_v2"] = {"hipblasCsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr_v2"] = {"hipblasZsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher_v2"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher_v2"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR/HPR - //cuda2hipRename["cublasSspr_v2"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr_v2"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr_v2"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr_v2"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr_v2"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr_v2"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr_v2"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr_v2"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2/HER2 - //cuda2hipRename["cublasSsyr2_v2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2_v2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2_v2"] = {"hipblasCsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2_v2"] = {"hipblasZsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher2_v2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2_v2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2_v2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2_v2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2_v2"] = {"hipblasCsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2_v2"] = {"hipblasZsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher2_v2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2_v2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR2/HPR2 - //cuda2hipRename["cublasSspr2_v2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr2_v2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr2_v2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr2_v2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr2_v2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr2_v2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr2_v2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr2_v2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas3 (v2) Routines // GEMM - cuda2hipRename["cublasSgemm_v2"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemm_v2"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasCgemm_v2"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemm_v2"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemm_v2"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemm_v2"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + + cuda2hipRename["cublasCgemm_v2"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemm_v2"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; //IO in FP16 / FP32, computation in float - // cublasSgemmEx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgemmEx"] = {"hipblasSgemmEx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRK - //cuda2hipRename["cublasSsyrk_v2"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyrk_v2"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyrk_v2"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyrk_v2"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrk_v2"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrk_v2"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrk_v2"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrk_v2"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERK - //cuda2hipRename["cublasCherk_v2"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZherk_v2"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherk_v2"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherk_v2"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2K - //cuda2hipRename["cublasSsyr2k_v2"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2k_v2"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2k_v2"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2k_v2"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2k_v2"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2k_v2"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2k_v2"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2k_v2"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HER2K - //cuda2hipRename["cublasCher2k_v2"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2k_v2"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCher2k_v2"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2k_v2"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMM - //cuda2hipRename["cublasSsymm_v2"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymm_v2"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymm_v2"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymm_v2"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymm_v2"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymm_v2"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymm_v2"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymm_v2"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HEMM - //cuda2hipRename["cublasChemm_v2"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemm_v2"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasChemm_v2"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemm_v2"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - //cuda2hipRename["cublasStrsm_v2"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsm_v2"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsm_v2"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsm_v2"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsm_v2"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsm_v2"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsm_v2"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsm_v2"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMM - //cuda2hipRename["cublasStrmm_v2"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmm_v2"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmm_v2"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmm_v2"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmm_v2"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmm_v2"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmm_v2"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmm_v2"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // NRM2 - //cuda2hipRename["cublasSnrm2_v2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDnrm2_v2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScnrm2_v2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDznrm2_v2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSnrm2_v2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDnrm2_v2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasScnrm2_v2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDznrm2_v2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DOT - cuda2hipRename["cublasSdot_v2"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDdot_v2"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotu_v2"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotc_v2"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotu_v2"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotc_v2"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdot_v2"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdot_v2"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; + + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCdotu_v2"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdotc_v2"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotu_v2"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotc_v2"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SCAL - cuda2hipRename["cublasSscal_v2"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDscal_v2"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCscal_v2"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsscal_v2"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZscal_v2"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdscal_v2"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscal_v2"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscal_v2"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCscal_v2"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsscal_v2"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZscal_v2"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdscal_v2"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AXPY - cuda2hipRename["cublasSaxpy_v2"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDaxpy_v2"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCaxpy_v2"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZaxpy_v2"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpy_v2"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDaxpy_v2"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCaxpy_v2"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZaxpy_v2"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // COPY - cuda2hipRename["cublasScopy_v2"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDcopy_v2"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCcopy_v2"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZcopy_v2"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopy_v2"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopy_v2"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCcopy_v2"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZcopy_v2"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SWAP - //cuda2hipRename["cublasSswap_v2"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDswap_v2"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCswap_v2"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZswap_v2"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSswap_v2"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDswap_v2"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCswap_v2"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZswap_v2"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMAX - //cuda2hipRename["cublasIsamax_v2"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamax_v2"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamax_v2"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamax_v2"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamax_v2"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamax_v2"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamax_v2"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamax_v2"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMIN - //cuda2hipRename["cublasIsamin_v2"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamin_v2"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamin_v2"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamin_v2"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamin_v2"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamin_v2"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamin_v2"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamin_v2"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ASUM - cuda2hipRename["cublasSasum_v2"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDasum_v2"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScasum_v2"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDzasum_v2"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasum_v2"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasum_v2"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasScasum_v2"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDzasum_v2"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROT - //cuda2hipRename["cublasSrot_v2"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrot_v2"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrot_v2"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsrot_v2"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrot_v2"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdrot_v2"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrot_v2"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrot_v2"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrot_v2"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsrot_v2"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrot_v2"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdrot_v2"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTG - //cuda2hipRename["cublasSrotg_v2"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotg_v2"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrotg_v2"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrotg_v2"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotg_v2"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotg_v2"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrotg_v2"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrotg_v2"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTM - //cuda2hipRename["cublasSrotm_v2"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotm_v2"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotm_v2"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotm_v2"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTMG - //cuda2hipRename["cublasSrotmg_v2"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotmg_v2"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; } - - struct HipNames { - StringRef hipName; - ConvTypes countType; - ApiTypes countApiType; - }; - - SmallDenseMap cuda2hipRename; - std::set cudaExcludes; }; StringRef unquoteStr(StringRef s) { @@ -1333,39 +2309,134 @@ StringRef unquoteStr(StringRef s) { return s; } -static void processString(StringRef s, const cuda2hipMap &map, - Replacements *Replace, SourceManager &SM, - SourceLocation start, - int64_t countReps[CONV_LAST], - int64_t countApiReps[API_LAST]) { - size_t begin = 0; - while ((begin = s.find("cu", begin)) != StringRef::npos) { - const size_t end = s.find_first_of(" ", begin + 4); - StringRef name = s.slice(begin, end); - const auto found = map.cuda2hipRename.find(name); - if (found != map.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[CONV_LITERAL]++; - countApiReps[API_RUNTIME]++; - SourceLocation sl = start.getLocWithOffset(begin + 1); - Replacement Rep(SM, sl, name.size(), repName); - Replace->insert(Rep); +class Cuda2Hip { +public: + Cuda2Hip(Replacements *R, const std::string &srcFileName) : + Replace(R), mainFileName(srcFileName) {} + uint64_t countReps[CONV_LAST] = { 0 }; + uint64_t countApiReps[API_LAST] = { 0 }; + uint64_t countRepsUnsupported[CONV_LAST] = { 0 }; + uint64_t countApiRepsUnsupported[API_LAST] = { 0 }; + std::map cuda2hipConverted; + std::map cuda2hipUnconverted; + std::set LOCs; + + enum msgTypes { + HIPIFY_ERROR = 0, + HIPIFY_WARNING + }; + + std::string getMsgType(msgTypes type) { + switch (type) { + case HIPIFY_ERROR: return "error"; + default: + case HIPIFY_WARNING: return "warning"; } - if (end == StringRef::npos) - break; - begin = end + 1; } -} + +protected: + struct cuda2hipMap N; + Replacements *Replace; + std::string mainFileName; + + virtual void insertReplacement(const Replacement &rep, const FullSourceLoc &fullSL) { + Replace->insert(rep); + if (PrintStats) { + LOCs.insert(fullSL.getExpansionLineNumber()); + } + } + void insertHipHeaders(Cuda2Hip *owner, const SourceManager &SM) { + if (owner->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { + std::string repName = "#include "; + hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter, repName); + SourceLocation sl = SM.getLocForStartOfFile(SM.getMainFileID()); + FullSourceLoc fullSL(sl, SM); + Replacement Rep(SM, sl, 0, repName + "\n"); + insertReplacement(Rep, fullSL); + } + } + + void printHipifyMessage(const SourceManager &SM, const SourceLocation &sl, const std::string &message, msgTypes msgType = HIPIFY_WARNING) { + FullSourceLoc fullSL(sl, SM); + llvm::errs() << "[HIPIFY] " << getMsgType(msgType) << ": " << mainFileName << ":" << fullSL.getExpansionLineNumber() << ":" << fullSL.getExpansionColumnNumber() << ": " << message << "\n"; + } + + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { + std::map *map = &cuda2hipConverted; + std::map *mapTotal = &cuda2hipConvertedTotal; + if (counter.unsupported) { + map = &cuda2hipUnconverted; + mapTotal = &cuda2hipUnconvertedTotal; + } + auto found = map->find(cudaName); + if (found == map->end()) { + map->insert(std::pair(cudaName, 1)); + } else { + found->second++; + } + auto foundT = mapTotal->find(cudaName); + if (foundT == mapTotal->end()) { + mapTotal->insert(std::pair(cudaName, 1)); + } else { + foundT->second++; + } + } + + virtual void updateCounters(const hipCounter &counter, const std::string &cudaName) { + if (!PrintStats) { + return; + } + updateCountersExt(counter, cudaName); + if (counter.unsupported) { + countRepsUnsupported[counter.countType]++; + countRepsTotalUnsupported[counter.countType]++; + countApiRepsUnsupported[counter.countApiType]++; + countApiRepsTotalUnsupported[counter.countApiType]++; + } else { + countReps[counter.countType]++; + countRepsTotal[counter.countType]++; + countApiReps[counter.countApiType]++; + countApiRepsTotal[counter.countApiType]++; + } + } + + void processString(StringRef s, SourceManager &SM, SourceLocation start) { + size_t begin = 0; + while ((begin = s.find("cu", begin)) != StringRef::npos) { + const size_t end = s.find_first_of(" ", begin + 4); + StringRef name = s.slice(begin, end); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + StringRef repName = found->second.hipName; + hipCounter counter = {"", CONV_LITERAL, API_RUNTIME, found->second.unsupported}; + updateCounters(counter, name.str()); + if (!counter.unsupported) { + SourceLocation sl = start.getLocWithOffset(begin + 1); + Replacement Rep(SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, SM); + insertReplacement(Rep, fullSL); + } + } else { + // std::string msg = "the following reference is not handled: '" + name.str() + "' [string literal]."; + // printHipifyMessage(SM, start, msg); + } + if (end == StringRef::npos) { + break; + } + begin = end + 1; + } + } +}; class Cuda2HipCallback; -class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks { +class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks, public Cuda2Hip { public: - HipifyPPCallbacks(Replacements *R) - : SeenEnd(false), _sm(nullptr), _pp(nullptr), Replace(R) {} + HipifyPPCallbacks(Replacements *R, const std::string &mainFileName) + : Cuda2Hip(R, mainFileName), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} - virtual bool handleBeginSource(CompilerInstance &CI, - StringRef Filename) override { + virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { Preprocessor &PP = CI.getPreprocessor(); SourceManager &SM = CI.getSourceManager(); setSourceManager(&SM); @@ -1388,21 +2459,24 @@ public: if (is_angled) { const auto found = N.cuda2hipRename.find(file_name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - DEBUG(dbgs() << "Include file found: " << file_name << "\n" - << "SourceLocation:" - << filename_range.getBegin().printToString(*_sm) << "\n" - << "Will be replaced with " << repName << "\n"); - SourceLocation sl = filename_range.getBegin(); - SourceLocation sle = filename_range.getEnd(); - const char *B = _sm->getCharacterData(sl); - const char *E = _sm->getCharacterData(sle); - SmallString<128> tmpData; - Replacement Rep(*_sm, sl, E - B, - Twine("<" + repName + ">").toStringRef(tmpData)); - Replace->insert(Rep); + updateCounters(found->second, file_name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + DEBUG(dbgs() << "Include file found: " << file_name << "\n" + << "SourceLocation: " + << filename_range.getBegin().printToString(*_sm) << "\n" + << "Will be replaced with " << repName << "\n"); + SourceLocation sl = filename_range.getBegin(); + SourceLocation sle = filename_range.getEnd(); + const char *B = _sm->getCharacterData(sl); + const char *E = _sm->getCharacterData(sle); + SmallString<128> tmpData; + Replacement Rep(*_sm, sl, E - B, Twine("<" + repName + ">").toStringRef(tmpData)); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); + } + } else { +// llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; } } } @@ -1417,18 +2491,20 @@ public: StringRef name = T.getIdentifierInfo()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - SourceLocation sl = T.getLocation(); - DEBUG(dbgs() << "Identifier " << name - << " found in definition of macro " - << MacroNameTok.getIdentifierInfo()->getName() << "\n" - << "will be replaced with: " << repName << "\n" - << "SourceLocation: " << sl.printToString(*_sm) - << "\n"); - Replacement Rep(*_sm, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = T.getLocation(); + DEBUG(dbgs() << "Identifier " << name << " found in definition of macro " + << MacroNameTok.getIdentifierInfo()->getName() << "\n" + << "will be replaced with: " << repName << "\n" + << "SourceLocation: " << sl.printToString(*_sm) << "\n"); + Replacement Rep(*_sm, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); + } + } else { + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro].\n"; } } } @@ -1439,66 +2515,78 @@ public: const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override { if (_sm->isWrittenInMainFile(MacroNameTok.getLocation())) { - StringRef macroName = MacroNameTok.getIdentifierInfo()->getName(); - if (N.cudaExcludes.end() == N.cudaExcludes.find(macroName)) { - for (unsigned int i = 0; Args && i < MD.getMacroInfo()->getNumArgs(); i++) { - std::vector toks; - // Code below is a kind of stolen from 'MacroArgs::getPreExpArgument' - // to workaround the 'const' MacroArgs passed into this hook. - const Token *start = Args->getUnexpArgument(i); - size_t len = Args->getArgLength(start) + 1; - #if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) - _pp->EnterTokenStream(ArrayRef(start, len), false); - #else - _pp->EnterTokenStream(start, len, false, false); - #endif - do { - toks.push_back(Token()); - Token &tk = toks.back(); - _pp->Lex(tk); - } while (toks.back().isNot(tok::eof)); - _pp->RemoveTopOfLexerStack(); - // end of stolen code - for (auto tok : toks) { - if (tok.isAnyIdentifier()) { - StringRef name = tok.getIdentifierInfo()->getName(); + for (unsigned int i = 0; Args && i < MD.getMacroInfo()->getNumArgs(); i++) { + std::vector toks; + // Code below is a kind of stolen from 'MacroArgs::getPreExpArgument' + // to workaround the 'const' MacroArgs passed into this hook. + const Token *start = Args->getUnexpArgument(i); + size_t len = Args->getArgLength(start) + 1; +#if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) + _pp->EnterTokenStream(ArrayRef(start, len), false); +#else + _pp->EnterTokenStream(start, len, false, false); +#endif + do { + toks.push_back(Token()); + Token &tk = toks.back(); + _pp->Lex(tk); + } while (toks.back().isNot(tok::eof)); + _pp->RemoveTopOfLexerStack(); + // end of stolen code + for (auto tok : toks) { + if (tok.isAnyIdentifier()) { + StringRef name = tok.getIdentifierInfo()->getName(); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + DEBUG(dbgs() << "Identifier " << name + << " found as an actual argument in expansion of macro " + << MacroNameTok.getIdentifierInfo()->getName() << "\n" + << "will be replaced with: " << repName << "\n"); + size_t length = name.size(); + SourceLocation sl = tok.getLocation(); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + name = StringRef(_sm->getCharacterData(sl_macro), length); + sl = sl_macro; + } + Replacement Rep(*_sm, sl, length, repName); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); + } + } else { + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; + } + } else if (tok.isLiteral()) { + SourceLocation sl = tok.getLocation(); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + size_t length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - DEBUG(dbgs() - << "Identifier " << name - << " found as an actual argument in expansion of macro " - << macroName << "\n" - << "will be replaced with: " << repName << "\n"); - SourceLocation sl = tok.getLocation(); - Replacement Rep(*_sm, sl, name.size(), repName); - Replace->insert(Rep); - } - } else if (tok.isLiteral()) { - SourceLocation sl = tok.getLocation(); - if (_sm->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = _sm->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); - size_t length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); - StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); - const auto found = N.cuda2hipRename.find(name); - if (found != N.cuda2hipRename.end()) { - sl = sl_macro; + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + sl = sl_macro; Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { - if (tok.is(tok::string_literal)) { - StringRef s(tok.getLiteralData(), tok.getLength()); - processString(unquoteStr(s), N, Replace, *_sm, tok.getLocation(), - countReps, countApiReps); - } + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; + } + } else { + if (tok.is(tok::string_literal)) { + StringRef s(tok.getLiteralData(), tok.getLength()); + processString(unquoteStr(s), *_sm, tok.getLocation()); } } } @@ -1513,30 +2601,22 @@ public: void setSourceManager(SourceManager *sm) { _sm = sm; } void setPreprocessor(Preprocessor *pp) { _pp = pp; } void setMatch(Cuda2HipCallback *match) { Match = match; } - int64_t countReps[CONV_LAST] = { 0 }; - int64_t countApiReps[API_LAST] = { 0 }; private: SourceManager *_sm; Preprocessor *_pp; Cuda2HipCallback *Match; - Replacements *Replace; - struct cuda2hipMap N; }; -class Cuda2HipCallback : public MatchFinder::MatchCallback { +class Cuda2HipCallback : public MatchFinder::MatchCallback, public Cuda2Hip { private: void convertKernelDecl(const FunctionDecl *kernelDecl, const MatchFinder::MatchResult &Result) { SourceManager *SM = Result.SourceManager; LangOptions DefaultLangOptions; SmallString<40> XStr; raw_svector_ostream OS(XStr); - StringRef initialParamList; - OS << "hipLaunchParm lp"; - size_t repLength = OS.str().size(); SourceLocation sl = kernelDecl->getNameInfo().getEndLoc(); - SourceLocation kernelArgListStart = Lexer::findLocationAfterToken( - sl, tok::l_paren, *SM, DefaultLangOptions, true); + SourceLocation kernelArgListStart = Lexer::findLocationAfterToken(sl, tok::l_paren, *SM, DefaultLangOptions, true); DEBUG(dbgs() << kernelArgListStart.printToString(*SM)); if (kernelDecl->getNumParams() > 0) { const ParmVarDecl *pvdFirst = kernelDecl->getParamDecl(0); @@ -1544,46 +2624,52 @@ private: SourceLocation kernelArgListStart(pvdFirst->getLocStart()); SourceLocation kernelArgListEnd(pvdLast->getLocEnd()); SourceLocation stop = Lexer::getLocForEndOfToken(kernelArgListEnd, 0, *SM, DefaultLangOptions); - repLength += SM->getCharacterData(stop) - SM->getCharacterData(kernelArgListStart); - initialParamList = StringRef(SM->getCharacterData(kernelArgListStart), repLength); - OS << ", " << initialParamList; + size_t repLength = SM->getCharacterData(stop) - SM->getCharacterData(kernelArgListStart); + OS << StringRef(SM->getCharacterData(kernelArgListStart), repLength); + Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); + FullSourceLoc fullSL(sl, *(Result.SourceManager)); + insertReplacement(Rep0, fullSL); } - DEBUG(dbgs() << "initial paramlist: " << initialParamList << "\n" << "new paramlist: " << OS.str() << "\n"); - Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); - Replace->insert(Rep0); } bool cudaCall(const MatchFinder::MatchResult &Result) { if (const CallExpr *call = Result.Nodes.getNodeAs("cudaCall")) { const FunctionDecl *funcDcl = call->getDirectCallee(); StringRef name = funcDcl->getDeclName().getAsString(); + SourceManager *SM = Result.SourceManager; + SourceLocation sl = call->getLocStart(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - SourceManager *SM = Result.SourceManager; - StringRef repName = found->second.hipName; - SourceLocation sl = call->getLocStart(); - size_t length = name.size(); - bool bReplace = true; - if (SM->isMacroArgExpansion(sl)) { - sl = SM->getImmediateSpellingLoc(sl); - } else if (SM->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = SM->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *SM, DefaultLangOptions); - length = SM->getCharacterData(sl_end) - SM->getCharacterData(sl_macro); - StringRef macroName = StringRef(SM->getCharacterData(sl_macro), length); - if (N.cudaExcludes.end() != N.cudaExcludes.find(macroName)) { - bReplace = false; - } else { - sl = sl_macro; + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + size_t length = name.size(); + bool bReplace = true; + if (SM->isMacroArgExpansion(sl)) { + sl = SM->getImmediateSpellingLoc(sl); + } else if (SM->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = SM->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *SM, DefaultLangOptions); + length = SM->getCharacterData(sl_end) - SM->getCharacterData(sl_macro); + StringRef macroName = StringRef(SM->getCharacterData(sl_macro), length); + if (N.cudaExcludes.end() != N.cudaExcludes.find(macroName)) { + bReplace = false; + } else { + sl = sl_macro; + } } + if (bReplace) { + updateCounters(found->second, name.str()); + Replacement Rep(*SM, sl, length, repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + updateCounters(found->second, name.str()); } - if (bReplace) { - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - Replacement Rep(*SM, sl, length, repName); - Replace->insert(Rep); - } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [function call]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -1591,7 +2677,8 @@ private: } bool cudaLaunchKernel(const MatchFinder::MatchResult &Result) { - if (const CUDAKernelCallExpr *launchKernel = Result.Nodes.getNodeAs("cudaLaunchKernel")) { + StringRef refName = "cudaLaunchKernel"; + if (const CUDAKernelCallExpr *launchKernel = Result.Nodes.getNodeAs(refName)) { SmallString<40> XStr; raw_svector_ostream OS(XStr); StringRef calleeName; @@ -1605,16 +2692,15 @@ private: dyn_cast(e)) { calleeName = ule->getName().getAsIdentifierInfo()->getName(); owner->addMatcher(functionTemplateDecl(hasName(calleeName)) - .bind("unresolvedTemplateName"), - this); + .bind("unresolvedTemplateName"), this); } } XStr.clear(); if (calleeName.find(',') != StringRef::npos) { SmallString<128> tmpData; - calleeName = Twine("HIP_KERNEL_NAME(" + calleeName + ")").toStringRef(tmpData); + calleeName = Twine("(" + calleeName + ")").toStringRef(tmpData); } - OS << "hipLaunchKernel(" << calleeName << ","; + OS << "hipLaunchKernelGGL(" << calleeName << ","; const CallExpr *config = launchKernel->getConfig(); DEBUG(dbgs() << "Kernel config arguments:" << "\n"); SourceManager *SM = Result.SourceManager; @@ -1652,9 +2738,10 @@ private: launchKernel->getLocEnd(), 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchKernel->getLocStart()); Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); - Replace->insert(Rep); - countReps[CONV_KERN]++; - countApiReps[API_RUNTIME]++; + FullSourceLoc fullSL(launchKernel->getLocStart(), *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = {"hipLaunchKernelGGL", CONV_KERN, API_RUNTIME}; + updateCounters(counter, refName.str()); return true; } return false; @@ -1666,6 +2753,8 @@ private: dyn_cast(threadIdx->getBase())) { if (const DeclRefExpr *declRef = dyn_cast(refBase->getSourceExpr())) { + SourceLocation sl = threadIdx->getLocStart(); + SourceManager *SM = Result.SourceManager; StringRef name = declRef->getDecl()->getName(); StringRef memberName = threadIdx->getMemberDecl()->getName(); size_t pos = memberName.find_first_not_of("__fetch_builtin_"); @@ -1674,13 +2763,16 @@ private: name = Twine(name + "." + memberName).toStringRef(tmpData); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - SourceLocation sl = threadIdx->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [builtin]."; + printHipifyMessage(*SM, sl, msg); } } } @@ -1692,15 +2784,20 @@ private: bool cudaEnumConstantRef(const MatchFinder::MatchResult &Result) { if (const DeclRefExpr *enumConstantRef = Result.Nodes.getNodeAs("cudaEnumConstantRef")) { StringRef name = enumConstantRef->getDecl()->getNameAsString(); + SourceLocation sl = enumConstantRef->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - SourceLocation sl = enumConstantRef->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant ref]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -1716,15 +2813,20 @@ private: QualType QT = enumConstantDecl->getType().getUnqualifiedType(); name = QT.getAsString(); } + SourceLocation sl = enumConstantDecl->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - SourceLocation sl = enumConstantDecl->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -1739,15 +2841,50 @@ private: } QT = QT.getUnqualifiedType(); StringRef name = QT.getAsString(); + SourceLocation sl = typedefVar->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - SourceLocation sl = typedefVar->getLocStart(); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var]."; + printHipifyMessage(*SM, sl, msg); + } + return true; + } + return false; + } + + bool cudaTypedefVarPtr(const MatchFinder::MatchResult &Result) { + if (const VarDecl *typedefVarPtr = Result.Nodes.getNodeAs("cudaTypedefVarPtr")) { + const Type *t = typedefVarPtr->getType().getTypePtrOrNull(); + if (t) { SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + QualType QT = t->getPointeeType(); + QT = QT.getUnqualifiedType(); + StringRef name = QT.getAsString(); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } + else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var ptr]."; + printHipifyMessage(*SM, sl, msg); + } } return true; } @@ -1756,20 +2893,27 @@ private: bool cudaStructVar(const MatchFinder::MatchResult &Result) { if (const VarDecl *structVar = Result.Nodes.getNodeAs("cudaStructVar")) { - StringRef name = structVar->getType() - ->getAsStructureType() - ->getDecl() - ->getNameAsString(); - const auto found = N.cuda2hipRename.find(name); - if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + QualType QT = structVar->getType(); + // ToDo: find case-studies with types other than Struct. + if (QT->isStructureType()) { + StringRef name = QT.getTypePtr()->getAsStructureType()->getDecl()->getNameAsString(); TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } + else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; + printHipifyMessage(*SM, sl, msg); + } } return true; } @@ -1780,17 +2924,22 @@ private: if (const VarDecl *structVarPtr = Result.Nodes.getNodeAs("cudaStructVarPtr")) { const Type *t = structVarPtr->getType().getTypePtrOrNull(); if (t) { + TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; StringRef name = t->getPointeeCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -1801,19 +2950,28 @@ private: bool cudaStructSizeOf(const MatchFinder::MatchResult &Result) { if (const UnaryExprOrTypeTraitExpr *expr = Result.Nodes.getNodeAs("cudaStructSizeOf")) { TypeSourceInfo *typeInfo = expr->getArgumentTypeInfo(); + TypeLoc TL = typeInfo->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; QualType QT = typeInfo->getType().getUnqualifiedType(); const Type *type = QT.getTypePtr(); - StringRef name = type->getAsCXXRecordDecl()->getName(); + CXXRecordDecl *rec = type->getAsCXXRecordDecl(); + if (!rec) { + return false; + } + StringRef name = rec->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - TypeLoc TL = typeInfo->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct sizeof]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -1821,7 +2979,8 @@ private: } bool cudaSharedIncompleteArrayVar(const MatchFinder::MatchResult &Result) { - if (const VarDecl *sharedVar = Result.Nodes.getNodeAs("cudaSharedIncompleteArrayVar")) { + StringRef refName = "cudaSharedIncompleteArrayVar"; + if (const VarDecl *sharedVar = Result.Nodes.getNodeAs(refName)) { // Example: extern __shared__ uint sRadix1[]; if (sharedVar->hasExternalFormalLinkage()) { QualType QT = sharedVar->getType(); @@ -1851,9 +3010,10 @@ private: StringRef varName = sharedVar->getNameAsString(); StringRef repName = Twine("HIP_DYNAMIC_SHARED(" + typeName + ", " + varName + ")").toStringRef(tmpData); Replacement Rep(*SM, slStart, repLength, repName); - Replace->insert(Rep); - countReps[CONV_MEM]++; - countApiReps[API_RUNTIME]++; + FullSourceLoc fullSL(slStart, *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = { "HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME }; + updateCounters(counter, refName.str()); } } return true; @@ -1869,16 +3029,21 @@ private: if (t->isStructureOrClassType()) { name = t->getAsCXXRecordDecl()->getName(); } + TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -1889,6 +3054,9 @@ private: if (const ParmVarDecl *paramDeclPtr = Result.Nodes.getNodeAs("cudaParamDeclPtr")) { const Type *pt = paramDeclPtr->getType().getTypePtrOrNull(); if (pt) { + TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; QualType QT = pt->getPointeeType(); const Type *t = QT.getTypePtr(); StringRef name = t->isStructureOrClassType() @@ -1896,14 +3064,16 @@ private: : StringRef(QT.getAsString()); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; - TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -1925,7 +3095,7 @@ private: if (sLiteral->getCharByteWidth() == 1) { StringRef s = sLiteral->getString(); SourceManager *SM = Result.SourceManager; - processString(s, N, Replace, *SM, sLiteral->getLocStart(), countReps, countApiReps); + processString(s, *SM, sLiteral->getLocStart()); } return true; } @@ -1933,105 +3103,50 @@ private: } public: - Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks) - : Replace(Replace), owner(parent), PP(PPCallbacks) { + Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks, const std::string &mainFileName) + : Cuda2Hip(Replace, mainFileName), owner(parent), PP(PPCallbacks) { PP->setMatch(this); } void run(const MatchFinder::MatchResult &Result) override { do { if (cudaCall(Result)) break; - if (cudaLaunchKernel(Result)) break; if (cudaBuiltin(Result)) break; if (cudaEnumConstantRef(Result)) break; if (cudaEnumConstantDecl(Result)) break; if (cudaTypedefVar(Result)) break; + if (cudaTypedefVarPtr(Result)) break; if (cudaStructVar(Result)) break; if (cudaStructVarPtr(Result)) break; if (cudaStructSizeOf(Result)) break; - if (cudaSharedIncompleteArrayVar(Result)) break; if (cudaParamDecl(Result)) break; if (cudaParamDeclPtr(Result)) break; + if (cudaLaunchKernel(Result)) break; + if (cudaSharedIncompleteArrayVar(Result)) break; if (stringLiteral(Result)) break; if (unresolvedTemplateName(Result)) break; break; } while (false); - if (PP->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && - countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { - StringRef repName = "#include \n"; - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, SM->getLocForStartOfFile(SM->getMainFileID()), 0, repName); - Replace->insert(Rep); - countReps[CONV_INCLUDE_CUDA_MAIN_H]++; - countApiReps[API_RUNTIME]++; - } + insertHipHeaders(PP, *Result.SourceManager); } - int64_t countReps[CONV_LAST] = { 0 }; - int64_t countApiReps[API_LAST] = { 0 }; - private: - Replacements *Replace; ast_matchers::MatchFinder *owner; HipifyPPCallbacks *PP; - struct cuda2hipMap N; }; void HipifyPPCallbacks::handleEndSource() { - if (Match->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && - countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { - StringRef repName = "#include \n"; - Replacement Rep(*_sm, _sm->getLocForStartOfFile(_sm->getMainFileID()), 0, repName); - Replace->insert(Rep); - countReps[CONV_INCLUDE_CUDA_MAIN_H]++; - countApiReps[API_RUNTIME]++; - } + insertHipHeaders(Match, *_sm); } } // end anonymous namespace -// Set up the command line options -static cl::OptionCategory ToolTemplateCategory("CUDA to HIP source translator options"); - -static cl::opt OutputFilename("o", - cl::desc("Output filename"), - cl::value_desc("filename"), - cl::cat(ToolTemplateCategory)); - -static cl::opt Inplace("inplace", - cl::desc("Modify input file inplace, replacing input with hipified " - "output, save backup in .prehip file"), - cl::value_desc("inplace"), - cl::cat(ToolTemplateCategory)); - -static cl::opt NoBackup("no-backup", - cl::desc("Don't create a backup file for the hipified source"), - cl::value_desc("no-backup"), - cl::cat(ToolTemplateCategory)); - -static cl::opt NoOutput("no-output", - cl::desc("Don't write any translated output to stdout"), - cl::value_desc("no-output"), - cl::cat(ToolTemplateCategory)); - -static cl::opt PrintStats("print-stats", - cl::desc("Print translation statistics"), - cl::value_desc("print-stats"), - cl::cat(ToolTemplateCategory)); - -static cl::opt N("n", - cl::desc("Combines -no-output and -print-stats options"), - cl::value_desc("n"), - cl::cat(ToolTemplateCategory)); - -static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); - void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callback) { Finder.addMatcher(callExpr(isExpansionInMainFile(), callee(functionDecl(matchesName("cu.*")))) .bind("cudaCall"), Callback); - Finder.addMatcher(cudaKernelCallExpr().bind("cudaLaunchKernel"), Callback); + Finder.addMatcher(cudaKernelCallExpr(isExpansionInMainFile()).bind("cudaLaunchKernel"), Callback); Finder.addMatcher(memberExpr(isExpansionInMainFile(), hasObjectExpression(hasType(cxxRecordDecl( matchesName("__cuda_builtin_"))))) @@ -2050,19 +3165,32 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac hasType(typedefDecl(matchesName("cu.*|CU.*")))) .bind("cudaTypedefVar"), Callback); - // Array of elements of typedef type, Example: cudaStream_t streams[2]; + // Array of elements of typedef type. Example: + // cudaStream_t streams[2]; Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(arrayType(hasElementType(typedefType( hasDeclaration(typedefDecl(matchesName("cu.*|CU.*")))))))) .bind("cudaTypedefVar"), Callback); + // Pointer to typedef type. Examples: + // 1. + // cudaEvent_t *event = NULL; + // typedef __device_builtin__ struct CUevent_st *cudaEvent_t; + // 2. + // CUevent *event = NULL; + // typedef struct CUevent_st *CUevent; + Finder.addMatcher(varDecl(isExpansionInMainFile(), + hasType(pointsTo(typedefDecl( + matchesName("cu.*|CU.*"))))) + .bind("cudaTypedefVarPtr"), + Callback); Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(cxxRecordDecl(matchesName("cu.*|CU.*")))) .bind("cudaStructVar"), Callback); Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(pointsTo(cxxRecordDecl( - matchesName("cu.*|CU.*"))))) + matchesName("cu.*|CU.*"))))) .bind("cudaStructVarPtr"), Callback); Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), @@ -2071,12 +3199,12 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), hasType(pointsTo(namedDecl( - matchesName("cu.*|CU.*"))))) + matchesName("cu.*|CU.*"))))) .bind("cudaParamDeclPtr"), Callback); Finder.addMatcher(expr(isExpansionInMainFile(), - sizeOfExpr(hasArgumentOfType(recordType(hasDeclaration( - cxxRecordDecl(matchesName("cu.*|CU.*"))))))) + sizeOfExpr(hasArgumentOfType( + recordType(hasDeclaration(cxxRecordDecl(matchesName("cu.*|CU.*"))))))) .bind("cudaStructSizeOf"), Callback); Finder.addMatcher(stringLiteral(isExpansionInMainFile()).bind("stringLiteral"), @@ -2088,118 +3216,397 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); } -void printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { - int64_t sum = 0; +int64_t printStats(const std::string &csvFile, const std::string &srcFile, + HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback, + uint64_t replacedBytes, uint64_t totalBytes, unsigned totalLines, + const std::chrono::steady_clock::time_point &start) { + std::ofstream csv(csvFile, std::ios::app); + int64_t sum = 0, sum_interm = 0; + std::string str; + const std::string hipify_info = "[HIPIFY] info: ", separator = ";"; for (int i = 0; i < CONV_LAST; i++) { sum += Callback.countReps[i] + PPCallbacks.countReps[i]; } - llvm::outs() << "info: converted " << sum << " CUDA->HIP refs ( "; + int64_t sum_unsupported = 0; for (int i = 0; i < CONV_LAST; i++) { - llvm::outs() << counterNames[i] << ':' << Callback.countReps[i] + PPCallbacks.countReps[i] << ' '; + sum_unsupported += Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; } - llvm::outs() << "), by APIs ( "; - for (int i = 0; i < API_LAST; i++) { - llvm::outs() << apiNames[i] << ':' << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << ' '; + if (sum > 0 || sum_unsupported > 0) { + str = "file \'" + srcFile + "\' statistics:\n"; + llvm::outs() << "\n" << hipify_info << str; + csv << "\n" << str; + str = "CONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum << "\n"; + csv << "\n" << str << separator << sum << "\n"; + str = "UNCONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum_unsupported << "\n"; + csv << str << separator << sum_unsupported << "\n"; + str = "CONVERSION %"; + long conv = 100 - std::lround(double(sum_unsupported*100)/double(sum + sum_unsupported)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + str = "REPLACED bytes"; + llvm::outs() << " " << str << ": " << replacedBytes << "\n"; + csv << str << separator << replacedBytes << "\n"; + str = "TOTAL bytes"; + llvm::outs() << " " << str << ": " << totalBytes << "\n"; + csv << str << separator << totalBytes << "\n"; + str = "CHANGED lines of code"; + unsigned changedLines = Callback.LOCs.size() + PPCallbacks.LOCs.size(); + llvm::outs() << " " << str << ": " << changedLines << "\n"; + csv << str << separator << changedLines << "\n"; + str = "TOTAL lines of code"; + llvm::outs() << " " << str << ": " << totalLines << "\n"; + csv << str << separator << totalLines << "\n"; + if (totalBytes > 0) { + str = "CODE CHANGED (in bytes) %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + if (totalLines > 0) { + str = "CODE CHANGED (in lines) %"; + conv = std::lround(double(changedLines * 100) / double(totalLines)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + typedef std::chrono::duration duration; + duration elapsed = std::chrono::steady_clock::now() - start; + str = "TIME ELAPSED s"; + std::stringstream stream; + stream << std::fixed << std::setprecision(2) << elapsed.count() / 1000; + llvm::outs() << " " << str << ": " << stream.str() << "\n"; + csv << str << separator << stream.str() << "\n"; } - llvm::outs() << ") in \'" << fileSource << "\'\n"; + if (sum > 0) { + llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; + csv << "\nCUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = Callback.countReps[i] + PPCallbacks.countReps[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by API:\n"; + csv << "\nCUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << "\n"; + csv << apiNames[i] << separator << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << "\n"; + } + for (const auto & it : PPCallbacks.cuda2hipConverted) { + const auto found = Callback.cuda2hipConverted.find(it.first); + if (found == Callback.cuda2hipConverted.end()) { + Callback.cuda2hipConverted.insert(std::pair(it.first, 1)); + } else { + found->second += it.second; + } + } + llvm::outs() << hipify_info << "CONVERTED refs by names:\n"; + csv << "\nCUDA ref name" << separator << "Count\n"; + for (const auto & it : Callback.cuda2hipConverted) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + if (sum_unsupported > 0) { + str = "UNCONVERTED refs by type:"; + llvm::outs() << hipify_info << str << "\n"; + csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by API:\n"; + csv << "\nUNCONVERTED CUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << "\n"; + csv << apiNames[i] << separator << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << "\n"; + } + for (const auto & it : PPCallbacks.cuda2hipUnconverted) { + const auto found = Callback.cuda2hipUnconverted.find(it.first); + if (found == Callback.cuda2hipUnconverted.end()) { + Callback.cuda2hipUnconverted.insert(std::pair(it.first, 1)); + } else { + found->second += it.second; + } + } + llvm::outs() << hipify_info << "UNCONVERTED refs by names:\n"; + csv << "\nUNCONVERTED CUDA ref name" << separator << "Count\n"; + for (const auto & it : Callback.cuda2hipUnconverted) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + csv.close(); + return sum; +} + +void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles, + uint64_t replacedBytes, uint64_t totalBytes, unsigned changedLines, unsigned totalLines, + const std::chrono::steady_clock::time_point &start) { + std::ofstream csv(csvFile, std::ios::app); + int64_t sum = 0, sum_interm = 0; + std::string str; + const std::string hipify_info = "[HIPIFY] info: ", separator = ";"; + for (int i = 0; i < CONV_LAST; i++) { + sum += countRepsTotal[i]; + } + int64_t sum_unsupported = 0; + for (int i = 0; i < CONV_LAST; i++) { + sum_unsupported += countRepsTotalUnsupported[i]; + } + if (sum > 0 || sum_unsupported > 0) { + str = "TOTAL statistics:\n"; + llvm::outs() << "\n" << hipify_info << str; + csv << "\n" << str; + str = "CONVERTED files"; + llvm::outs() << " " << str << ": " << convertedFiles << "\n"; + csv << "\n" << str << separator << convertedFiles << "\n"; + str = "PROCESSED files"; + llvm::outs() << " " << str << ": " << totalFiles << "\n"; + csv << str << separator << totalFiles << "\n"; + str = "CONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum << "\n"; + csv << str << separator << sum << "\n"; + str = "UNCONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum_unsupported << "\n"; + csv << str << separator << sum_unsupported << "\n"; + str = "CONVERSION %"; + long conv = 100 - std::lround(double(sum_unsupported * 100) / double(sum + sum_unsupported)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + str = "REPLACED bytes"; + llvm::outs() << " " << str << ": " << replacedBytes << "\n"; + csv << str << separator << replacedBytes << "\n"; + str = "TOTAL bytes"; + llvm::outs() << " " << str << ": " << totalBytes << "\n"; + csv << str << separator << totalBytes << "\n"; + str = "CHANGED lines of code"; + llvm::outs() << " " << str << ": " << changedLines << "\n"; + csv << str << separator << changedLines << "\n"; + str = "TOTAL lines of code"; + llvm::outs() << " " << str << ": " << totalLines << "\n"; + csv << str << separator << totalLines << "\n"; + if (totalBytes > 0) { + str = "CODE CHANGED (in bytes) %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + if (totalLines > 0) { + str = "CODE CHANGED (in lines) %"; + conv = std::lround(double(changedLines * 100) / double(totalLines)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + typedef std::chrono::duration duration; + duration elapsed = std::chrono::steady_clock::now() - start; + str = "TIME ELAPSED s"; + std::stringstream stream; + stream << std::fixed << std::setprecision(2) << elapsed.count() / 1000; + llvm::outs() << " " << str << ": " << stream.str() << "\n"; + csv << str << separator << stream.str() << "\n"; + } + if (sum > 0) { + llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; + csv << "\nCUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = countRepsTotal[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by API:\n"; + csv << "\nCUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << countApiRepsTotal[i] << "\n"; + csv << apiNames[i] << separator << countApiRepsTotal[i] << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by names:\n"; + csv << "\nCUDA ref name" << separator << "Count\n"; + for (const auto & it : cuda2hipConvertedTotal) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + if (sum_unsupported > 0) { + str = "UNCONVERTED refs by type:"; + llvm::outs() << hipify_info << str << "\n"; + csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = countRepsTotalUnsupported[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by API:\n"; + csv << "\nUNCONVERTED CUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << countApiRepsTotalUnsupported[i] << "\n"; + csv << apiNames[i] << separator << countApiRepsTotalUnsupported[i] << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by names:\n"; + csv << "\nUNCONVERTED CUDA ref name" << separator << "Count\n"; + for (const auto & it : cuda2hipUnconvertedTotal) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + csv.close(); } int main(int argc, const char **argv) { + auto start = std::chrono::steady_clock::now(); + auto begin = start; llvm::sys::PrintStackTraceOnErrorSignal(); - CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::Required); + CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::OneOrMore); std::vector fileSources = OptionsParser.getSourcePathList(); std::string dst = OutputFilename; - if (N) { - NoOutput = PrintStats = true; + if (!dst.empty() && fileSources.size() > 1) { + llvm::errs() << "[HIPIFY] conflict: -o and multiple source files are specified.\n"; + return 1; } if (NoOutput) { if (Inplace) { - llvm::errs() << "Conflict: both -no-output and -inplace options are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: both -no-output and -inplace options are specified.\n"; return 1; } if (!dst.empty()) { - llvm::errs() << "Conflict: both -no-output and -o options are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: both -no-output and -o options are specified.\n"; return 1; } } - if (dst.empty()) { - dst = fileSources[0]; - if (!Inplace) { + if (Examine) { + NoOutput = PrintStats = true; + } + int Result = 0; + std::string csv; + if (!OutputStatsFilename.empty()) { + csv = OutputStatsFilename; + } else { + csv = "hipify_stats.csv"; + } + size_t filesTranslated = fileSources.size(); + uint64_t repBytesTotal = 0; + uint64_t bytesTotal = 0; + unsigned changedLinesTotal = 0; + unsigned linesTotal = 0; + if (PrintStats && filesTranslated > 1) { + std::remove(csv.c_str()); + } + for (const auto & src : fileSources) { + if (dst.empty()) { + dst = src; + if (!Inplace) { + size_t pos = dst.rfind("."); + if (pos != std::string::npos && pos + 1 < dst.size()) { + dst = dst.substr(0, pos) + ".hip." + dst.substr(pos + 1, dst.size() - pos - 1); + } else { + dst += ".hip.cu"; + } + } + } else { + if (Inplace) { + llvm::errs() << "[HIPIFY] conflict: both -o and -inplace options are specified.\n"; + return 1; + } + dst += ".hip"; + } + // backup source file since tooling may change "inplace" + if (!NoBackup || !Inplace) { + std::ifstream source(src, std::ios::binary); + std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); + dest << source.rdbuf(); + source.close(); + dest.close(); + } + RefactoringTool Tool(OptionsParser.getCompilations(), dst); + ast_matchers::MatchFinder Finder; + HipifyPPCallbacks PPCallbacks(&Tool.getReplacements(), src); + Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks, src); + + addAllMatchers(Finder, &Callback); + + auto action = newFrontendActionFactory(&Finder, &PPCallbacks); + std::vector compilationStages; + compilationStages.push_back("--cuda-host-only"); + + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(compilationStages[0], ArgumentInsertPosition::BEGIN)); + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); +#if defined(HIPIFY_CLANG_RES) + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-resource-dir=" HIPIFY_CLANG_RES)); +#endif + Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); + Result += Tool.run(action.get()); + Tool.clearArgumentsAdjusters(); + + LangOptions DefaultLangOptions; + IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); + TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); + DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, &DiagnosticPrinter, false); + + uint64_t repBytes = 0; + uint64_t bytes = 0; + unsigned lines = 0; + SourceManager SM(Diagnostics, Tool.getFiles()); + if (PrintStats) { + DEBUG(dbgs() << "Replacements collected by the tool:\n"); + for (const auto &r : Tool.getReplacements()) { + DEBUG(dbgs() << r.toString() << "\n"); + repBytes += r.getLength(); + } + std::ifstream src_file(dst, std::ios::binary | std::ios::ate); + src_file.clear(); + src_file.seekg(0); + lines = std::count(std::istreambuf_iterator(src_file), std::istreambuf_iterator(), '\n'); + bytes = src_file.tellg(); + } + Rewriter Rewrite(SM, DefaultLangOptions); + if (!Tool.applyAllReplacements(Rewrite)) { + DEBUG(dbgs() << "Skipped some replacements.\n"); + } + if (!NoOutput) { + Result += Rewrite.overwriteChangedFiles(); + } + if (!Inplace && !NoOutput) { size_t pos = dst.rfind("."); - if (pos != std::string::npos && pos+1 < dst.size()) { - dst = dst.substr(0, pos) + ".hip." + dst.substr(pos+1, dst.size()-pos-1); - } else { - dst += ".hip.cu"; + if (pos != std::string::npos) { + rename(dst.c_str(), dst.substr(0, pos).c_str()); } } - } else { - if (Inplace) { - llvm::errs() << "Conflict: both -o and -inplace options are specified.\n"; - return 1; + if (NoOutput) { + remove(dst.c_str()); } - dst += ".hip"; - } - // backup source file since tooling may change "inplace" - if (!NoBackup || !Inplace) { - std::ifstream source(fileSources[0], std::ios::binary); - std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); - dest << source.rdbuf(); - source.close(); - dest.close(); - } - - RefactoringTool Tool(OptionsParser.getCompilations(), dst); - ast_matchers::MatchFinder Finder; - HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); - Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks); - - addAllMatchers(Finder, &Callback); - - auto action = newFrontendActionFactory(&Finder, &PPCallbacks); - std::vector compilationStages; - compilationStages.push_back("--cuda-host-only"); - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(compilationStages[0], ArgumentInsertPosition::BEGIN)); - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); -#if defined(HIPIFY_CLANG_RES) - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-resource-dir=" HIPIFY_CLANG_RES)); -#endif - Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); - int Result = Tool.run(action.get()); - Tool.clearArgumentsAdjusters(); - - LangOptions DefaultLangOptions; - IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); - TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); - DiagnosticsEngine Diagnostics( - IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, - &DiagnosticPrinter, false); - - DEBUG(dbgs() << "Replacements collected by the tool:\n"); - for (const auto &r : Tool.getReplacements()) { - DEBUG(dbgs() << r.toString() << "\n"); - } - - SourceManager Sources(Diagnostics, Tool.getFiles()); - Rewriter Rewrite(Sources, DefaultLangOptions); - - if (!Tool.applyAllReplacements(Rewrite)) { - DEBUG(dbgs() << "Skipped some replacements.\n"); - } - if (!NoOutput) { - Result = Rewrite.overwriteChangedFiles(); - } - if (!Inplace && !NoOutput) { - size_t pos = dst.rfind("."); - if (pos != std::string::npos) { - rename(dst.c_str(), dst.substr(0, pos).c_str()); + if (PrintStats) { + if (fileSources.size() == 1) { + if (OutputStatsFilename.empty()) { + csv = dst + ".csv"; + } + std::remove(csv.c_str()); + } + if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes, lines, start)) { + filesTranslated--; + } + start = std::chrono::steady_clock::now(); + repBytesTotal += repBytes; + bytesTotal += bytes; + changedLinesTotal += PPCallbacks.LOCs.size() + Callback.LOCs.size(); + linesTotal += lines; } + dst.clear(); } - if (NoOutput) { - remove(dst.c_str()); + if (PrintStats && fileSources.size() > 1) { + printAllStats(csv, fileSources.size(), filesTranslated, repBytesTotal, bytesTotal, changedLinesTotal, linesTotal, begin); } - if (PrintStats) { - printStats(fileSources[0], PPCallbacks, Callback); - } - return Result; } diff --git a/projects/hip/include/hip/channel_descriptor.h b/projects/hip/include/hip/channel_descriptor.h new file mode 100644 index 0000000000..b8e750b079 --- /dev/null +++ b/projects/hip/include/hip/channel_descriptor.h @@ -0,0 +1,39 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_CHANNEL_DESCRIPTOR_H + +// Some standard header files, these are included by hc.hpp and so want to make them avail on both +// paths to provide a consistent include env and avoid "missing symbol" errors that only appears +// on NVCC path: + + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/include/hip/device_functions.h b/projects/hip/include/hip/device_functions.h new file mode 100644 index 0000000000..aae6775d48 --- /dev/null +++ b/projects/hip/include/hip/device_functions.h @@ -0,0 +1,36 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_DEVICE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_DEVICE_FUNCTIONS_H + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/include/hip/driver_types.h b/projects/hip/include/hip/driver_types.h new file mode 100644 index 0000000000..5d06457dd5 --- /dev/null +++ b/projects/hip/include/hip/driver_types.h @@ -0,0 +1,36 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_DRIVER_TYPES_H +#define HIP_INCLUDE_HIP_DRIVER_TYPES_H + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include "driver_types.h" +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/include/hip/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h new file mode 100644 index 0000000000..4be023f6ca --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -0,0 +1,382 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H + +#include +#include + +#ifdef __cplusplus + +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); + +static inline hipChannelFormatDesc hipCreateChannelDescHalf() { + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +static inline hipChannelFormatDesc hipCreateChannelDescHalf1() { + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +static inline hipChannelFormatDesc hipCreateChannelDescHalf2() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template +static inline hipChannelFormatDesc hipCreateChannelDesc() { + return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +#else + +struct hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, enum hipChannelFormatKind f); + +#endif + +#endif diff --git a/projects/hip/include/hip/hcc.h b/projects/hip/include/hip/hcc_detail/concepts.hpp similarity index 87% rename from projects/hip/include/hip/hcc.h rename to projects/hip/include/hip/hcc_detail/concepts.hpp index dba26aeab3..5c50f5d577 100644 --- a/projects/hip/include/hip/hcc.h +++ b/projects/hip/include/hip/hcc_detail/concepts.hpp @@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_H -#define HIP_HCC_H +#pragma once -#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) -#include "hip/hcc_detail/hcc_acc.h" -#endif +namespace hip_impl // Documentation only. +{ + #define requires(...) -#endif + #define FunctionalProcedure typename +} diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h new file mode 100644 index 0000000000..8073503364 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -0,0 +1,604 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H + +#include +#include + + + + + +// Single Precision Fast Math +__device__ float __cosf(float x); +__device__ float __exp10f(float x); +__device__ float __expf(float x); +__device__ static float __fadd_rd(float x, float y); +__device__ static float __fadd_rn(float x, float y); +__device__ static float __fadd_ru(float x, float y); +__device__ static float __fadd_rz(float x, float y); +__device__ static float __fdiv_rd(float x, float y); +__device__ static float __fdiv_rn(float x, float y); +__device__ static float __fdiv_ru(float x, float y); +__device__ static float __fdiv_rz(float x, float y); +__device__ static float __fdividef(float x, float y); +__device__ float __fmaf_rd(float x, float y, float z); +__device__ float __fmaf_rn(float x, float y, float z); +__device__ float __fmaf_ru(float x, float y, float z); +__device__ float __fmaf_rz(float x, float y, float z); +__device__ static float __fmul_rd(float x, float y); +__device__ static float __fmul_rn(float x, float y); +__device__ static float __fmul_ru(float x, float y); +__device__ static float __fmul_rz(float x, float y); +__device__ float __frcp_rd(float x); +__device__ float __frcp_rn(float x); +__device__ float __frcp_ru(float x); +__device__ float __frcp_rz(float x); +__device__ float __frsqrt_rn(float x); +__device__ float __fsqrt_rd(float x); +__device__ float __fsqrt_rn(float x); +__device__ float __fsqrt_ru(float x); +__device__ float __fsqrt_rz(float x); +__device__ static float __fsub_rd(float x, float y); +__device__ static float __fsub_rn(float x, float y); +__device__ static float __fsub_ru(float x, float y); +__device__ float __log10f(float x); +__device__ float __log2f(float x); +__device__ float __logf(float x); +__device__ float __powf(float base, float exponent); +__device__ static float __saturatef(float x); +__device__ void __sincosf(float x, float *s, float *c); +__device__ float __sinf(float x); +__device__ float __tanf(float x); + + +/* +Double Precision Intrinsics +*/ + +__device__ static double __dadd_rd(double x, double y); +__device__ static double __dadd_rn(double x, double y); +__device__ static double __dadd_ru(double x, double y); +__device__ static double __dadd_rz(double x, double y); +__device__ static double __ddiv_rd(double x, double y); +__device__ static double __ddiv_rn(double x, double y); +__device__ static double __ddiv_ru(double x, double y); +__device__ static double __ddiv_rz(double x, double y); +__device__ static double __dmul_rd(double x, double y); +__device__ static double __dmul_rn(double x, double y); +__device__ static double __dmul_ru(double x, double y); +__device__ static double __dmul_rz(double x, double y); +__device__ double __drcp_rd(double x); +__device__ double __drcp_rn(double x); +__device__ double __drcp_ru(double x); +__device__ double __drcp_rz(double x); +__device__ double __dsqrt_rd(double x); +__device__ double __dsqrt_rn(double x); +__device__ double __dsqrt_ru(double x); +__device__ double __dsqrt_rz(double x); +__device__ static double __dsub_rd(double x, double y); +__device__ static double __dsub_rn(double x, double y); +__device__ static double __dsub_ru(double x, double y); +__device__ static double __dsub_rz(double x, double y); +__device__ double __fma_rd(double x, double y, double z); +__device__ double __fma_rn(double x, double y, double z); +__device__ double __fma_ru(double x, double y, double z); +__device__ double __fma_rz(double x, double y, double z); + +// Single Precision Fast Math +extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); +extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); +__device__ float __hip_fast_exp10f(float); +__device__ float __hip_fast_expf(float); +__device__ float __hip_fast_frsqrt_rn(float); +extern __attribute__((const)) float __hip_fast_fsqrt_rd(float) __asm("llvm.sqrt.f32"); +__device__ float __hip_fast_fsqrt_rn(float); +__device__ float __hip_fast_fsqrt_ru(float); +__device__ float __hip_fast_fsqrt_rz(float); +__device__ float __hip_fast_log10f(float); +extern __attribute__((const)) float __hip_fast_log2f(float) __asm("llvm.log2.f32"); +__device__ float __hip_fast_logf(float); +__device__ float __hip_fast_powf(float, float); +__device__ void __hip_fast_sincosf(float,float*,float*); +extern __attribute__((const)) float __hip_fast_sinf(float) __asm("llvm.sin.f32"); +__device__ float __hip_fast_tanf(float); +extern __attribute__((const)) float __hip_fast_fmaf(float,float,float) __asm("llvm.fma.f32"); +extern __attribute__((const)) float __hip_fast_frcp(float) __asm("llvm.amdgcn.rcp.f32"); + +extern __attribute__((const)) double __hip_fast_dsqrt(double) __asm("llvm.sqrt.f64"); +extern __attribute__((const)) double __hip_fast_fma(double,double,double) __asm("llvm.fma.f64"); +extern __attribute__((const)) double __hip_fast_drcp(double) __asm("llvm.amdgcn.rcp.f64"); + + +// Single Precision Fast Math +__device__ inline float __cosf(float x) { + return __hip_fast_cosf(x); +} + +__device__ inline float __exp10f(float x) { + return __hip_fast_exp10f(x); +} + +__device__ inline float __expf(float x) { + return __hip_fast_expf(x); +} + +__device__ static inline float __fadd_rd(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_rn(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_ru(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_rz(float x, float y) { + return x + y; +} + +__device__ static inline float __fdiv_rd(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_rn(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_ru(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_rz(float x, float y) { + return x / y; +} + +__device__ static inline float __fdividef(float x, float y) { + return x / y; +} + +__device__ inline float __fmaf_rd(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rn(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_ru(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rz(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ static inline float __fmul_rd(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_rn(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_ru(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_rz(float x, float y) { + return x * y; +} + +__device__ inline float __frcp_rd(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rn(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_ru(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rz(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frsqrt_rn(float x) { + return __hip_fast_frsqrt_rn(x); +} + +__device__ inline float __fsqrt_rd(float x) { + return __hip_fast_fsqrt_rd(x); +} + +__device__ inline float __fsqrt_rn(float x) { + return __hip_fast_fsqrt_rn(x); +} + +__device__ inline float __fsqrt_ru(float x) { + return __hip_fast_fsqrt_ru(x); +} + +__device__ inline float __fsqrt_rz(float x) { + return __hip_fast_fsqrt_rz(x); +} + +__device__ static inline float __fsub_rd(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_rn(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_ru(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_rz(float x, float y) { + return x - y; +} + + +__device__ inline float __log10f(float x) { + return __hip_fast_log10f(x); +} + +__device__ inline float __log2f(float x) { + return __hip_fast_log2f(x); +} + +__device__ inline float __logf(float x) { + return __hip_fast_logf(x); +} + +__device__ inline float __powf(float base, float exponent) { + return __hip_fast_powf(base, exponent); +} + +__device__ static inline float __saturatef(float x) { + x = x > 1.0f ? 1.0f : x; + x = x < 0.0f ? 0.0f : x; + return x; +} + +__device__ inline void __sincosf(float x, float *s, float *c) { + return __hip_fast_sincosf(x, s, c); +} + +__device__ inline float __sinf(float x) { + return __hip_fast_sinf(x); +} + +__device__ inline float __tanf(float x) { + return __hip_fast_tanf(x); +} + + +/* +Double Precision Intrinsics +*/ + +__device__ static inline double __dadd_rd(double x, double y) { + return x + y; +} + +__device__ static inline double __dadd_rn(double x, double y) { + return x + y; +} + +__device__ static inline double __dadd_ru(double x, double y) { + return x + y; +} + +__device__ static inline double __dadd_rz(double x, double y) { + return x + y; +} + +__device__ static inline double __ddiv_rd(double x, double y) { + return x / y; +} + +__device__ static inline double __ddiv_rn(double x, double y) { + return x / y; +} + +__device__ static inline double __ddiv_ru(double x, double y) { + return x / y; +} + +__device__ static inline double __ddiv_rz(double x, double y) { + return x / y; +} + +__device__ static inline double __dmul_rd(double x, double y) { + return x * y; +} + +__device__ static inline double __dmul_rn(double x, double y) { + return x * y; +} + +__device__ static inline double __dmul_ru(double x, double y) { + return x * y; +} + +__device__ static inline double __dmul_rz(double x, double y) { + return x * y; +} + +__device__ inline double __drcp_rd(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_rn(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_ru(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_rz(double x) { + return __hip_fast_drcp(x); +} + + +__device__ inline double __dsqrt_rd(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rn(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_ru(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rz(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ static inline double __dsub_rd(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_rn(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_ru(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_rz(double x, double y) { + return x - y; +} + +__device__ inline double __fma_rd(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rn(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_ru(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rz(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + + +extern "C" unsigned int __hip_hc_ir_umul24_int(unsigned int, unsigned int); +extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); +extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); +extern "C" unsigned int __hip_hc_ir_umulhi_int(unsigned int, unsigned int); +extern "C" unsigned int __hip_hc_ir_usad_int(unsigned int, unsigned int, unsigned int); + +// integer intrinsic function __poc __clz __ffs __brev +__device__ unsigned int __brev( unsigned int x); +__device__ unsigned long long int __brevll( unsigned long long int x); +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s); +__device__ unsigned int __clz(int x); +__device__ unsigned int __clzll(long long int x); +__device__ unsigned int __ffs(int x); +__device__ unsigned int __ffsll(long long int x); +__device__ static unsigned int __hadd(int x, int y); +__device__ static int __mul24(int x, int y); +__device__ long long int __mul64hi(long long int x, long long int y); +__device__ static int __mulhi(int x, int y); +__device__ unsigned int __popc(unsigned int x); +__device__ unsigned int __popcll(unsigned long long int x); +__device__ static int __rhadd(int x, int y); +__device__ static unsigned int __sad(int x, int y, int z); +__device__ static unsigned int __uhadd(unsigned int x, unsigned int y); +__device__ static int __umul24(unsigned int x, unsigned int y); +__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); +__device__ static unsigned int __umulhi(unsigned int x, unsigned int y); +__device__ static unsigned int __urhadd(unsigned int x, unsigned int y); +__device__ static unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + +__device__ static inline unsigned int __hadd(int x, int y) { + int z = x + y; + int sign = z & 0x8000000; + int value = z & 0x7FFFFFFF; + return ((value) >> 1 || sign); +} +__device__ static inline int __mul24(int x, int y) { + return __hip_hc_ir_mul24_int(x, y); +} +__device__ static inline int __mulhi(int x, int y) { + return __hip_hc_ir_mulhi_int(x, y); +} +__device__ static inline int __rhadd(int x, int y) { + int z = x + y + 1; + int sign = z & 0x8000000; + int value = z & 0x7FFFFFFF; + return ((value) >> 1 || sign); +} +__device__ static inline unsigned int __sad(int x, int y, int z) { + return x > y ? x - y + z : y - x + z; +} +__device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { + return (x + y) >> 1; +} +__device__ static inline int __umul24(unsigned int x, unsigned int y) { + return __hip_hc_ir_umul24_int(x, y); +} +__device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) { + return __hip_hc_ir_umulhi_int(x, y); +} +__device__ static inline unsigned int __urhadd(unsigned int x, unsigned int y) { + return (x + y + 1) >> 1; +} +__device__ static inline unsigned int __usad(unsigned int x, unsigned int y, unsigned int z) +{ + return __hip_hc_ir_usad_int(x, y, z); +} + +/* +Rounding modes are not yet supported in HIP +*/ + +__device__ float __double2float_rd(double x); +__device__ float __double2float_rn(double x); +__device__ float __double2float_ru(double x); +__device__ float __double2float_rz(double x); + +__device__ int __double2hiint(double x); + +__device__ int __double2int_rd(double x); +__device__ int __double2int_rn(double x); +__device__ int __double2int_ru(double x); +__device__ int __double2int_rz(double x); + +__device__ long long int __double2ll_rd(double x); +__device__ long long int __double2ll_rn(double x); +__device__ long long int __double2ll_ru(double x); +__device__ long long int __double2ll_rz(double x); + +__device__ int __double2loint(double x); + +__device__ unsigned int __double2uint_rd(double x); +__device__ unsigned int __double2uint_rn(double x); +__device__ unsigned int __double2uint_ru(double x); +__device__ unsigned int __double2uint_rz(double x); + +__device__ unsigned long long int __double2ull_rd(double x); +__device__ unsigned long long int __double2ull_rn(double x); +__device__ unsigned long long int __double2ull_ru(double x); +__device__ unsigned long long int __double2ull_rz(double x); + +__device__ long long int __double_as_longlong(double x); +/* +__device__ unsigned short __float2half_rn(float x); +__device__ float __half2float(unsigned short); + +The above device function are not a valid . +Use +__device__ __half __float2half_rn(float x); +__device__ float __half2float(__half); +from hip_fp16.h + +CUDA implements half as unsigned short whereas, HIP doesn't. + +*/ + +__device__ int __float2int_rd(float x); +__device__ int __float2int_rn(float x); +__device__ int __float2int_ru(float x); +__device__ int __float2int_rz(float x); + +__device__ long long int __float2ll_rd(float x); +__device__ long long int __float2ll_rn(float x); +__device__ long long int __float2ll_ru(float x); +__device__ long long int __float2ll_rz(float x); + +__device__ unsigned int __float2uint_rd(float x); +__device__ unsigned int __float2uint_rn(float x); +__device__ unsigned int __float2uint_ru(float x); +__device__ unsigned int __float2uint_rz(float x); + +__device__ unsigned long long int __float2ull_rd(float x); +__device__ unsigned long long int __float2ull_rn(float x); +__device__ unsigned long long int __float2ull_ru(float x); +__device__ unsigned long long int __float2ull_rz(float x); + +__device__ int __float_as_int(float x); +__device__ unsigned int __float_as_uint(float x); +__device__ double __hiloint2double(int hi, int lo); +__device__ double __int2double_rn(int x); + +__device__ float __int2float_rd(int x); +__device__ float __int2float_rn(int x); +__device__ float __int2float_ru(int x); +__device__ float __int2float_rz(int x); + +__device__ float __int_as_float(int x); + +__device__ double __ll2double_rd(long long int x); +__device__ double __ll2double_rn(long long int x); +__device__ double __ll2double_ru(long long int x); +__device__ double __ll2double_rz(long long int x); + +__device__ float __ll2float_rd(long long int x); +__device__ float __ll2float_rn(long long int x); +__device__ float __ll2float_ru(long long int x); +__device__ float __ll2float_rz(long long int x); + +__device__ double __longlong_as_double(long long int x); + +__device__ double __uint2double_rn(int x); + +__device__ float __uint2float_rd(unsigned int x); +__device__ float __uint2float_rn(unsigned int x); +__device__ float __uint2float_ru(unsigned int x); +__device__ float __uint2float_rz(unsigned int x); + +__device__ float __uint_as_float(unsigned int x); + +__device__ double __ull2double_rd(unsigned long long int x); +__device__ double __ull2double_rn(unsigned long long int x); +__device__ double __ull2double_ru(unsigned long long int x); +__device__ double __ull2double_rz(unsigned long long int x); + +__device__ float __ull2float_rd(unsigned long long int x); +__device__ float __ull2float_rn(unsigned long long int x); +__device__ float __ull2float_ru(unsigned long long int x); +__device__ float __ull2float_rz(unsigned long long int x); + +__device__ char4 __hip_hc_add8pk(char4, char4); +__device__ char4 __hip_hc_sub8pk(char4, char4); +__device__ char4 __hip_hc_mul8pk(char4, char4); + + +#endif diff --git a/projects/hip/include/hip/hcc_detail/driver_types.h b/projects/hip/include/hip/hcc_detail/driver_types.h new file mode 100644 index 0000000000..3578ddc609 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/driver_types.h @@ -0,0 +1,44 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H + +enum hipChannelFormatKind +{ + hipChannelFormatKindSigned = 0, + hipChannelFormatKindUnsigned = 1, + hipChannelFormatKindFloat = 2, + hipChannelFormatKindNone = 3 +}; + +struct hipChannelFormatDesc +{ + int x; + int y; + int z; + int w; + enum hipChannelFormatKind f; +}; + + +#endif diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp new file mode 100644 index 0000000000..2dd9a95bc6 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp @@ -0,0 +1,863 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#pragma once + +#if GENERIC_GRID_LAUNCH == 1 + +#include "concepts.hpp" +#include "helpers.hpp" + +#include "hc.hpp" +#include "hip_hcc.h" +#include "hip_runtime.h" + +#include +#include +#include +#include +#include + +namespace hip_impl +{ + namespace + { + struct New_grid_launch_tag {}; + struct Old_grid_launch_tag {}; + + template + class RAII_guard { + D dtor_; + public: + RAII_guard() = default; + + RAII_guard(const C& ctor, D dtor) : dtor_{std::move(dtor)} + { + ctor(); + } + + RAII_guard(const RAII_guard&) = default; + RAII_guard(RAII_guard&&) = default; + + RAII_guard& operator=(const RAII_guard&) = default; + RAII_guard& operator=(RAII_guard&&) = default; + + ~RAII_guard() { dtor_(); } + }; + + template + RAII_guard make_RAII_guard(const C& ctor, D dtor) + { + return RAII_guard{ctor, std::move(dtor)}; + } + + template + using is_new_grid_launch_t = typename std::conditional< + is_callable{}, + New_grid_launch_tag, + Old_grid_launch_tag>::type; + } + + // TODO: - dispatch rank should be derived from the domain dimensions passed + // in, and not always assumed to be 3; + + template + requires(Domain == {Ts...}) + inline + void grid_launch_hip_impl_( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + const hc::accelerator_view& acc_v, + K k, + Ts&&... args) + { + const auto d = hc::extent<3>{ + num_blocks.z * dim_blocks.z, + num_blocks.y * dim_blocks.y, + num_blocks.x * dim_blocks.x}.tile_with_dynamic( + dim_blocks.z, + dim_blocks.y, + dim_blocks.x, + group_mem_bytes); + + try { + hc::parallel_for_each( + acc_v, + d, + [=](const hc::tiled_index<3>& idx) [[hc]] { + k(args...); + }); + } + catch (std::exception& ex) { + std::cerr << "Failed in " << __FUNCTION__ << ", with exception: " + << ex.what() << std::endl; + throw; + } + } + + // TODO: these are workarounds, they should be removed. + + hc::accelerator_view lock_stream_hip_(hipStream_t&, void*&); + void print_prelaunch_trace_(const char*, dim3, dim3, int, hipStream_t); + void unlock_stream_hip_( + hipStream_t, void*, const char*, hc::accelerator_view*); + + template + requires(Domain == {Ts...}) + inline + void grid_launch_hip_impl_( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&&... args) + { + void* lck_stream = nullptr; + auto acc_v = lock_stream_hip_(stream, lck_stream); + auto stream_guard = make_RAII_guard( + std::bind( + print_prelaunch_trace_, + kernel_name, + num_blocks, + dim_blocks, + group_mem_bytes, + stream), + std::bind( + unlock_stream_hip_, stream, lck_stream, kernel_name, &acc_v)); + + try { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + acc_v, + std::move(k), + std::forward(args)...); + } + catch (std::exception& ex) { + std::cerr << "Failed in " << __FUNCTION__ << ", with exception: " + << ex.what() << std::endl; + throw; + } + } + + template + requires(Domain == {hipLaunchParm, Ts...}) + inline + void grid_launch_hip_impl_( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + K k, + Ts&&... args) + { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::move(k), + hipLaunchParm{}, + std::forward(args)...); + } + + template + requires(Domain == {hipLaunchParm, Ts...}) + inline + void grid_launch_hip_impl_( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&&... args) + { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + kernel_name, + std::move(k), + hipLaunchParm{}, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + inline + std::enable_if_t::value> grid_launch_hip_( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&& ... args) + { + grid_launch_hip_impl_( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + kernel_name, + std::move(k), + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + inline + std::enable_if_t::value> grid_launch_hip_( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + K k, + Ts&& ... args) + { + grid_launch_hip_impl_( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::move(k), + std::forward(args)...); + } + + namespace + { + template + constexpr + inline + T&& forward_(std::remove_reference_t& x) [[hc]] + { + return static_cast(x); + } + + template + struct Forwarder { + template + void operator()(Ts&&...args) const [[hc]] + { + k(forward_(args)...); + } + }; + } + + template + requires(Domain == {Ts...}) + inline + void grid_launch( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + Forwarder{}, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + inline + void grid_launch( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch_hip_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + hipLaunchParm{}, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + inline + std::enable_if_t::value> grid_launch_hip_( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch_hip_( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::forward(args)...); + } + + // TODO: these are temporary, they need to be completely removed once we + // enable C++14 support and can have proper generic, variadic lambdas. + #define make_kernel_lambda_hip_26(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22, p23, p24)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_,\ + const std::decay_t& _p23_,\ + const std::decay_t& _p24_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_, _p23_, _p24_);\ + } + #define make_kernel_lambda_hip_25(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22, p23)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_,\ + const std::decay_t& _p23_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_, _p23_);\ + } + #define make_kernel_lambda_hip_24(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_);\ + } + #define make_kernel_lambda_hip_23(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_);\ + } + #define make_kernel_lambda_hip_22(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_);\ + } + #define make_kernel_lambda_hip_21(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_);\ + } + #define make_kernel_lambda_hip_20(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_);\ + } + #define make_kernel_lambda_hip_19(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_);\ + } + #define make_kernel_lambda_hip_18(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_);\ + } + #define make_kernel_lambda_hip_17(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_);\ + } + #define make_kernel_lambda_hip_16(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_);\ + } + #define make_kernel_lambda_hip_15(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_);\ + } + #define make_kernel_lambda_hip_14(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_);\ + } + #define make_kernel_lambda_hip_13(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_);\ + } + #define make_kernel_lambda_hip_12(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_,\ + _p10_);\ + } + #define make_kernel_lambda_hip_11(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_);\ + } + #define make_kernel_lambda_hip_10(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_);\ + } + #define make_kernel_lambda_hip_9(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_);\ + } + #define make_kernel_lambda_hip_8(kernel_name, p0, p1, p2, p3, p4, p5, p6)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_);\ + } + #define make_kernel_lambda_hip_7(kernel_name, p0, p1, p2, p3, p4, p5)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_);\ + } + #define make_kernel_lambda_hip_6(kernel_name, p0, p1, p2, p3, p4)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_);\ + } + #define make_kernel_lambda_hip_5(kernel_name, p0, p1, p2, p3)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_);\ + } + #define make_kernel_lambda_hip_4(kernel_name, p0, p1, p2)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_);\ + } + #define make_kernel_lambda_hip_3(kernel_name, p0, p1)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_) [[hc]] {\ + kernel_name(_p0_, _p1_);\ + } + #define make_kernel_lambda_hip_2(kernel_name, p0)\ + [](const std::decay_t& _p0_) [[hc]] {\ + kernel_name(_p0_);\ + } + #define make_kernel_lambda_hip_1(kernel_name)\ + []() [[hc]] { return kernel_name(hipLaunchParm{}); } + + #define make_kernel_lambda_hip_(...)\ + overload_macro_hip_(make_kernel_lambda_hip_, __VA_ARGS__) + + #define hipLaunchKernelGGL(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + ...)\ + do {\ + hip_impl::grid_launch_hip_(\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + #kernel_name,\ + make_kernel_lambda_hip_(kernel_name, __VA_ARGS__),\ + ##__VA_ARGS__);\ + } while(0) + + #define hipLaunchKernel(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + ...)\ + do {\ + hipLaunchKernelGGL(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + hipLaunchParm{},\ + ##__VA_ARGS__);\ + } while(0) +} +#endif //GENERIC_GRID_LAUNCH diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp new file mode 100644 index 0000000000..611929766b --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -0,0 +1,134 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#pragma once +#include "concepts.hpp" + +#include // For std::conditional, std::decay, std::enable_if, + // std::false_type, std result_of and std::true_type. +#include // For std::declval. + +namespace std +{ // TODO: these should be removed as soon as possible. + #if (__cplusplus < 201406L) + #if (__cplusplus < 201402L) + template + using enable_if_t = typename enable_if::type; + template + using conditional_t = typename conditional::type; + template + using decay_t = typename decay::type; + template + using result_of_t = typename result_of::type; + template + using remove_reference_t = typename remove_reference::type; + #endif + #endif +} + +namespace hip_impl +{ + template + using void_t_ = void; + + #if (__cplusplus < 201402L) + template< + FunctionalProcedure F, + unsigned int n = 0u, + typename = void> + struct is_callable_impl : is_callable_impl {}; + + // Pointer to member function, call through non-pointer. + template + struct is_callable_impl< + F(C, Ts...), + 0u, + void_t_().*std::declval())( + std::declval()...))> + > : std::true_type {}; + + // Pointer to member function, call through pointer. + template + struct is_callable_impl< + F(C, Ts...), + 1u, + void_t_()).*std::declval())( + std::declval()...))> + > : std::true_type {}; + + // Pointer to member data, call through non-pointer, no args. + template + struct is_callable_impl< + F(C), + 2u, + void_t_().*std::declval())> + > : std::true_type {}; + + // Pointer to member data, call through pointer, no args. + template + struct is_callable_impl< + F(C), + 3u, + void_t_().*std::declval())> + > : std::true_type {}; + + // General call, n args. + template + struct is_callable_impl< + F(Ts...), + 4u, + void_t_()(std::declval()...))> + > : std::true_type {}; + + // Not callable. + template + struct is_callable_impl : std::false_type {}; + + template + struct is_callable : is_callable_impl {}; + #else + template + struct is_callable_impl : std::false_type {}; + + template + struct is_callable_impl< + F(Ts...), + void_t_>> : std::true_type {}; + #endif + + #define count_macro_args_impl_hip_(\ + _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\ + _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29,\ + _30, _31, _n, ...)\ + _n + #define count_macro_args_hip_(...)\ + count_macro_args_impl_hip_(\ + , ##__VA_ARGS__, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,\ + 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + + #define overloaded_macro_expand_hip_(macro, arg_cnt) macro##arg_cnt + #define overload_macro_impl_hip_(macro, arg_cnt)\ + overloaded_macro_expand_hip_(macro, arg_cnt) + #define overload_macro_hip_(macro, ...)\ + overload_macro_impl_hip_(macro, count_macro_args_hip_(__VA_ARGS__))\ + (__VA_ARGS__) +} diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index 21995de096..c76d65b058 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,53 +20,202 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIPCOMPLEX_H -#define HIPCOMPLEX_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -typedef struct{ - float x; - float y; -}hipFloatComplex; +#include "hip/hcc_detail/hip_vector_types.h" +#include -__device__ static inline float hipCrealf(hipFloatComplex z){ +#if __cplusplus +#define COMPLEX_ADD_OP_OVERLOAD(type) \ +__device__ __host__ static inline type operator + (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x + rhs.x ; \ + ret.y = lhs.y + rhs.y ; \ + return ret; \ +} + +#define COMPLEX_SUB_OP_OVERLOAD(type) \ +__device__ __host__ static inline type operator - (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x - rhs.x; \ + ret.y = lhs.y - rhs.y; \ + return ret; \ +} + +#define COMPLEX_MUL_OP_OVERLOAD(type) \ +__device__ __host__ static inline type operator * (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x * rhs.x - lhs.y * rhs.y; \ + ret.y = lhs.x * rhs.y + lhs.y * rhs.x; \ + return ret; \ +} + +#define COMPLEX_DIV_OP_OVERLOAD(type) \ +__device__ __host__ static inline type operator / (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = (lhs.x * rhs.x + lhs.y * rhs.y); \ + ret.y = (rhs.x * lhs.y - lhs.x * rhs.y); \ + ret.x = ret.x / (rhs.x * rhs.x + rhs.y * rhs.y); \ + ret.y = ret.y / (rhs.x * rhs.x + rhs.y * rhs.y); \ + return ret; \ +} + +#define COMPLEX_ADD_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator += (type& lhs, const type& rhs) { \ + lhs.x += rhs.x; \ + lhs.y += rhs.y; \ + return lhs; \ +} + +#define COMPLEX_SUB_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator -= (type& lhs, const type& rhs) { \ + lhs.x -= rhs.x; \ + lhs.y -= rhs.y; \ + return lhs; \ +} + +#define COMPLEX_MUL_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator *= (type& lhs, const type& rhs) { \ + lhs = lhs * rhs; \ + return lhs; \ +} + +#define COMPLEX_DIV_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator /= (type& lhs, const type& rhs) { \ + lhs = lhs / rhs; \ + return lhs; \ +} + +#define COMPLEX_SCALAR_PRODUCT(type, type1) \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + return ret; \ +} + +#endif + +struct hipFloatComplex { + #ifdef __cplusplus + public: + __device__ __host__ hipFloatComplex() : x(0.0f), y(0.0f) {} + __device__ __host__ hipFloatComplex(float x) : x(x), y(0.0f) {} + __device__ __host__ hipFloatComplex(float x, float y) : x(x), y(y) {} + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed long long) + #endif + float x, y; +} __attribute__((aligned(8))); + +struct hipDoubleComplex { + #ifdef __cplusplus + public: + __device__ __host__ hipDoubleComplex() : x(0.0f), y(0.0f) {} + __device__ __host__ hipDoubleComplex(double x) : x(x), y(0.0f) {} + __device__ __host__ hipDoubleComplex(double x, double y) : x(x), y(y) {} + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed long long) + #endif + double x, y; +} __attribute__((aligned(16))); + +#if __cplusplus + +COMPLEX_ADD_OP_OVERLOAD(hipFloatComplex) +COMPLEX_SUB_OP_OVERLOAD(hipFloatComplex) +COMPLEX_MUL_OP_OVERLOAD(hipFloatComplex) +COMPLEX_DIV_OP_OVERLOAD(hipFloatComplex) +COMPLEX_ADD_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_SUB_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_MUL_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_DIV_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned short) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed short) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned int) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed int) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, float) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, double) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed long long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned long long) + +COMPLEX_ADD_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_SUB_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_MUL_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_DIV_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_ADD_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_SUB_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_MUL_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_DIV_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned short) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed short) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned int) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed int) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, float) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, double) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed long long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned long long) + +#endif + +__device__ __host__ static inline float hipCrealf(hipFloatComplex z){ return z.x; } -__device__ static inline float hipCimagf(hipFloatComplex z){ +__device__ __host__ static inline float hipCimagf(hipFloatComplex z){ return z.y; } -__device__ static inline hipFloatComplex make_hipFloatComplex(float a, float b){ +__device__ __host__ static inline hipFloatComplex make_hipFloatComplex(float a, float b){ hipFloatComplex z; z.x = a; z.y = b; return z; } -__device__ static inline hipFloatComplex hipConjf(hipFloatComplex z){ +__device__ __host__ static inline hipFloatComplex hipConjf(hipFloatComplex z){ hipFloatComplex ret; ret.x = z.x; ret.y = -z.y; return ret; } -__device__ static inline float hipCsqabsf(hipFloatComplex z){ +__device__ __host__ static inline float hipCsqabsf(hipFloatComplex z){ return z.x * z.x + z.y * z.y; } -__device__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x + q.x, p.y + q.y); } -__device__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x - q.x, p.y - q.y); } -__device__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x * q.x - p.y * q.y, p.y * q.x + p.x * q.y); } -__device__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q){ float sqabs = hipCsqabsf(q); hipFloatComplex ret; ret.x = (p.x * q.x + p.y * q.y)/sqabs; @@ -74,55 +223,51 @@ __device__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatCom return ret; } -__device__ static inline float hipCabsf(hipFloatComplex z){ +__device__ __host__ static inline float hipCabsf(hipFloatComplex z){ return sqrtf(hipCsqabsf(z)); } -typedef struct{ - double x; - double y; -}hipDoubleComplex; -__device__ static inline double hipCreal(hipDoubleComplex z){ +__device__ __host__ static inline double hipCreal(hipDoubleComplex z){ return z.x; } -__device__ static inline double hipCimag(hipDoubleComplex z){ +__device__ __host__ static inline double hipCimag(hipDoubleComplex z){ return z.y; } -__device__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b){ +__device__ __host__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b){ hipDoubleComplex z; z.x = a; z.y = b; return z; } -__device__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ +__device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ hipDoubleComplex ret; ret.x = z.x; ret.y = z.y; return ret; } -__device__ static inline double hipCsqabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCsqabs(hipDoubleComplex z){ return z.x * z.x + z.y * z.y; } -__device__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x + q.x, p.y + q.y); } -__device__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x - q.x, p.y - q.y); } -__device__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x * q.x - p.y * q.y, p.y * q.x + p.x * q.y); } -__device__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q){ double sqabs = hipCsqabs(q); hipDoubleComplex ret; ret.x = (p.x * q.x + p.y * q.y)/sqabs; @@ -130,28 +275,28 @@ __device__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleC return ret; } -__device__ static inline double hipCabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCabs(hipDoubleComplex z){ return sqrtf(hipCsqabs(z)); } typedef hipFloatComplex hipComplex; -__device__ static inline hipComplex make_hipComplex(float x, +__device__ __host__ static inline hipComplex make_hipComplex(float x, float y){ return make_hipFloatComplex(x, y); } -__device__ static inline hipFloatComplex hipComplexDoubleToFloat +__device__ __host__ static inline hipFloatComplex hipComplexDoubleToFloat (hipDoubleComplex z){ return make_hipFloatComplex((float)z.x, (float)z.y); } -__device__ static inline hipDoubleComplex hipComplexFloatToDouble +__device__ __host__ static inline hipDoubleComplex hipComplexFloatToDouble (hipFloatComplex z){ return make_hipDoubleComplex((double)z.x, (double)z.y); } -__device__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r){ +__device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r){ float real = (p.x * q.x) + r.x; float imag = (q.x * p.y) + r.y; @@ -161,7 +306,7 @@ __device__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComp return make_hipComplex(real, imag); } -__device__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ +__device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ float real = (p.x * q.x) + r.x; float imag = (q.x * p.y) + r.y; diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index bcf2605f28..0a861b64af 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,158 +20,467 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_FP16_H -#define HIP_FP16_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H -#include "hip/hip_runtime.h" +#include "hip/hcc_detail/hip_vector_types.h" -typedef struct{ - unsigned x: 16; -} __half; +#if __clang_major__ > 3 +typedef __fp16 __half; typedef struct __attribute__((aligned(4))){ - __half p,q; + union { + __half p[2]; + unsigned int q; + }; } __half2; typedef __half half; typedef __half2 half2; /* -Arithmetic functions +Half Arithmetic Functions */ - __device__ __half __hadd(const __half a, const __half b); - -__device__ __half __hadd_sat(const __half a, const __half b); - -__device__ __half __hfma(const __half a, const __half b, const __half c); - -__device__ __half __hfma_sat(const __half a, const __half b, const __half c); - -__device__ __half __hmul(const __half a, const __half b); - -__device__ __half __hmul_sat(const __half a, const __half b); - -__device__ __half __hneq(const __half a); - -__device__ __half __hsub(const __half a, const __half b); - -__device__ __half __hsub_sat(const __half a, const __half b); - - +__device__ __half __hadd_sat(__half a, __half b); +__device__ __half __hfma(__half a, __half b, __half c); +__device__ __half __hfma_sat(__half a, __half b, __half c); +__device__ __half __hmul(__half a, __half b); +__device__ __half __hmul_sat(__half a, __half b); +__device__ __half __hneg(__half a); +__device__ __half __hsub(__half a, __half b); +__device__ __half __hsub_sat(__half a, __half b); +__device__ __half hdiv(__half a, __half b); /* -Half2 Arithmetic Instructions +Half2 Arithmetic Functions */ -__device__ __half2 __hadd2(const __half2 a, const __half2 b); - -__device__ __half2 __hadd2_sat(const __half2 a, const __half2 b); - -__device__ __half2 __hfma2(const __half2 a, const __half2 b, const __half2 c); - -__device__ __half2 __hfma2_sat(const __half2 a, const __half2 b, const __half2 c); - -__device__ __half2 __hmul2(const __half2 a, const __half2 b); - -__device__ __half2 __hmul2_sat(const __half2 a, const __half2 b); - -__device__ __half2 __hneq2(const __half2 a); - -__device__ __half2 __hsub2(const __half2 a, const __half2 b); - -__device__ __half2 __hsub2_sat(const __half2 a, const __half2 b); +__device__ static __half2 __hadd2(__half2 a, __half2 b); +__device__ static __half2 __hadd2_sat(__half2 a, __half2 b); +__device__ static __half2 __hfma2(__half2 a, __half2 b, __half2 c); +__device__ static __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c); +__device__ static __half2 __hmul2(__half2 a, __half2 b); +__device__ static __half2 __hmul2_sat(__half2 a, __half2 b); +__device__ static __half2 __hsub2(__half2 a, __half2 b); +__device__ static __half2 __hneg2(__half2 a); +__device__ static __half2 __hsub2_sat(__half2 a, __half2 b); +__device__ static __half2 h2div(__half2 a, __half2 b); /* -Half Cmps +Half Comparision Functions */ -__device__ bool __heq(const __half a, const __half b); - -__device__ bool __hge(const __half a, const __half b); - -__device__ bool __hgt(const __half a, const __half b); - -__device__ bool __hisinf(const __half a); - -__device__ bool __hisnan(const __half a); - -__device__ bool __hle(const __half a, const __half b); - -__device__ bool __hlt(const __half a, const __half b); - -__device__ bool __hne(const __half a, const __half b); +__device__ bool __heq(__half a, __half b); +__device__ bool __hge(__half a, __half b); +__device__ bool __hgt(__half a, __half b); +__device__ bool __hisinf(__half a); +__device__ bool __hisnan(__half a); +__device__ bool __hle(__half a, __half b); +__device__ bool __hlt(__half a, __half b); +__device__ bool __hne(__half a, __half b); /* -Half2 Cmps +Half2 Comparision Functions */ -__device__ bool __hbeq2(const __half2 a, const __half2 b); - -__device__ bool __hbge2(const __half2 a, const __half2 b); - -__device__ bool __hbgt2(const __half2 a, const __half2 b); - -__device__ bool __hble2(const __half2 a, const __half2 b); - -__device__ bool __hblt2(const __half2 a, const __half2 b); - -__device__ bool __hbne2(const __half2 a, const __half2 b); - -__device__ __half2 __heq2(const __half2 a, const __half2 b); - -__device__ __half2 __hge2(const __half2 a, const __half2 b); - -__device__ __half2 __hgt2(const __half2 a, const __half2 b); - -__device__ __half2 __hisnan2(const __half2 a); - -__device__ __half2 __hle2(const __half2 a, const __half2 b); - -__device__ __half2 __hlt2(const __half2 a, const __half2 b); - -__device__ __half2 __hne2(const __half2 a, const __half2 b); - +__device__ bool __hbeq2(__half2 a, __half2 b); +__device__ bool __hbge2(__half2 a, __half2 b); +__device__ bool __hbgt2(__half2 a, __half2 b); +__device__ bool __hble2(__half2 a, __half2 b); +__device__ bool __hblt2(__half2 a, __half2 b); +__device__ bool __hbne2(__half2 a, __half2 b); +__device__ __half2 __heq2(__half2 a, __half2 b); +__device__ __half2 __hge2(__half2 a, __half2 b); +__device__ __half2 __hgt2(__half2 a, __half2 b); +__device__ __half2 __hisnan2(__half2 a); +__device__ __half2 __hle2(__half2 a, __half2 b); +__device__ __half2 __hlt2(__half2 a, __half2 b); +__device__ __half2 __hne2(__half2 a, __half2 b); /* -Half Cnvs and Data Mvmnt +Half Math Functions */ -__device__ __half2 __float22half2_rn(const float2 a); +__device__ static __half hceil(const __half h); +__device__ static __half hcos(const __half h); +__device__ static __half hexp(const __half h); +__device__ static __half hexp10(const __half h); +__device__ static __half hexp2(const __half h); +__device__ static __half hfloor(const __half h); +__device__ static __half hlog(const __half h); +__device__ static __half hlog10(const __half h); +__device__ static __half hlog2(const __half h); +//__device__ static __half hrcp(const __half h); +__device__ static __half hrint(const __half h); +__device__ static __half hsin(const __half h); +__device__ static __half hsqrt(const __half a); +__device__ static __half htrunc(const __half a); -__device__ __half __float2half(const float a); +/* +Half2 Math Functions +*/ -__device__ __half2 __float2half2_rn(const float a); +__device__ static __half2 h2ceil(const __half2 h); +__device__ static __half2 h2exp(const __half2 h); +__device__ static __half2 h2exp10(const __half2 h); +__device__ static __half2 h2exp2(const __half2 h); +__device__ static __half2 h2floor(const __half2 h); +__device__ static __half2 h2log(const __half2 h); +__device__ static __half2 h2log10(const __half2 h); +__device__ static __half2 h2log2(const __half2 h); +__device__ static __half2 h2rcp(const __half2 h); +__device__ static __half2 h2rsqrt(const __half2 h); +__device__ static __half2 h2sin(const __half2 h); +__device__ static __half2 h2sqrt(const __half2 h); -__device__ __half2 __floats2half2_rn(const float a, const float b); +/* +Half Conversion And Data Movement +*/ -__device__ float2 __half22float2(const __half2 a); - -__device__ float __half2float(const __half a); - -__device__ __half2 __half2half2(const __half a); - -__device__ __half2 __halves2half2(const __half a, const __half b); - -__device__ float __high2float(const __half2 a); - -__device__ __half __high2half(const __half2 a); - -__device__ __half2 __high2half2(const __half2 a); - -__device__ __half2 __highs2half2(const __half2 a, const __half2 b); - -__device__ float __low2float(const __half2 a); +__device__ __half2 __float22half2_rn(const float2 a); +__device__ __half __float2half(const float a); +__device__ __half2 __float2half2_rn(const float a); +__device__ __half __float2half_rd(const float a); +__device__ __half __float2half_rn(const float a); +__device__ __half __float2half_ru(const float a); +__device__ __half __float2half_rz(const float a); +__device__ __half2 __floats2half2_rn(const float a, const float b); +__device__ float2 __half22float2(const __half2 a); +__device__ float __half2float(const __half a); +__device__ __half2 half2half2(const __half a); +__device__ int __half2int_rd(__half h); +__device__ int __half2int_rn(__half h); +__device__ int __half2int_ru(__half h); +__device__ int __half2int_rz(__half h); +__device__ long long int __half2ll_rd(__half h); +__device__ long long int __half2ll_rn(__half h); +__device__ long long int __half2ll_ru(__half h); +__device__ long long int __half2ll_rz(__half h); +__device__ short __half2short_rd(__half h); +__device__ short __half2short_rn(__half h); +__device__ short __half2short_ru(__half h); +__device__ short __half2short_rz(__half h); +__device__ unsigned int __half2uint_rd(__half h); +__device__ unsigned int __half2uint_rn(__half h); +__device__ unsigned int __half2uint_ru(__half h); +__device__ unsigned int __half2uint_rz(__half h); +__device__ unsigned long long int __half2ull_rd(__half h); +__device__ unsigned long long int __half2ull_rn(__half h); +__device__ unsigned long long int __half2ull_ru(__half h); +__device__ unsigned long long int __half2ull_rz(__half h); +__device__ unsigned short int __half2ushort_rd(__half h); +__device__ unsigned short int __half2ushort_rn(__half h); +__device__ unsigned short int __half2ushort_ru(__half h); +__device__ unsigned short int __half2ushort_rz(__half h); +__device__ short int __half_as_short(const __half h); +__device__ unsigned short int __half_as_ushort(const __half h); +__device__ __half2 __halves2half2(const __half a, const __half b); +__device__ float __high2float(const __half2 a); +__device__ __half __high2half(const __half2 a); +__device__ __half2 __high2half2(const __half2 a); +__device__ __half2 __highs2half2(const __half2 a, const __half2 b); +__device__ __half __int2half_rd(int i); +__device__ __half __int2half_rn(int i); +__device__ __half __int2half_ru(int i); +__device__ __half __int2half_rz(int i); +__device__ __half __ll2half_rd(long long int i); +__device__ __half __ll2half_rn(long long int i); +__device__ __half __ll2half_ru(long long int i); +__device__ __half __ll2half_rz(long long int i); +__device__ float __low2float(const __half2 a); __device__ __half __low2half(const __half2 a); - -__device__ __half2 __low2half2(const __half2 a); - -__device__ __half2 __lows2half2(const __half2 a, const __half2 b); - -__device__ __half2 __lowhigh2highlow(const __half2 a); - __device__ __half2 __low2half2(const __half2 a, const __half2 b); +__device__ __half2 __low2half2(const __half2 a); +__device__ __half2 __lowhigh2highlow(const __half2 a); +__device__ __half2 __lows2half2(const __half2 a, const __half2 b); +__device__ __half __short2half_rd(short int i); +__device__ __half __short2half_rn(short int i); +__device__ __half __short2half_ru(short int i); +__device__ __half __short2half_rz(short int i); +__device__ __half __uint2half_rd(unsigned int i); +__device__ __half __uint2half_rn(unsigned int i); +__device__ __half __uint2half_ru(unsigned int i); +__device__ __half __uint2half_rz(unsigned int i); +__device__ __half __ull2half_rd(unsigned long long int i); +__device__ __half __ull2half_rn(unsigned long long int i); +__device__ __half __ull2half_ru(unsigned long long int i); +__device__ __half __ull2half_rz(unsigned long long int i); +__device__ __half __ushort2half_rd(unsigned short int i); +__device__ __half __ushort2half_rn(unsigned short int i); +__device__ __half __ushort2half_ru(unsigned short int i); +__device__ __half __ushort2half_rz(unsigned short int i); +__device__ __half __ushort_as_half(const unsigned short int i); + +extern "C" int __hip_hc_ir_hadd2_int(int, int); +extern "C" int __hip_hc_ir_hfma2_int(int, int, int); +extern "C" int __hip_hc_ir_hmul2_int(int, int); +extern "C" int __hip_hc_ir_hsub2_int(int, int); + +extern "C" __half __hip_hc_ir_hceil_half(__half) __asm("llvm.ceil.f16"); +extern "C" __half __hip_hc_ir_hcos_half(__half) __asm("llvm.cos.f16"); +extern "C" __half __hip_hc_ir_hexp2_half(__half) __asm("llvm.exp2.f16"); +extern "C" __half __hip_hc_ir_hfloor_half(__half) __asm("llvm.floor.f16"); +extern "C" __half __hip_hc_ir_hlog2_half(__half) __asm("llvm.log2.f16"); +extern "C" __half __hip_hc_ir_hrcp_half(__half) __asm("llvm.amdgcn.rcp.f16"); +extern "C" __half __hip_hc_ir_hrint_half(__half) __asm("llvm.rint.f16"); +extern "C" __half __hip_hc_ir_hrsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_hsin_half(__half) __asm("llvm.sin.f16"); +extern "C" __half __hip_hc_ir_hsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_htrunc_half(__half) __asm("llvm.trunc.f16"); + +extern "C" int __hip_hc_ir_h2ceil_int(int); +extern "C" int __hip_hc_ir_h2cos_int(int); +extern "C" int __hip_hc_ir_h2exp2_int(int); +extern "C" int __hip_hc_ir_h2floor_int(int); +extern "C" int __hip_hc_ir_h2log2_int(int); +extern "C" int __hip_hc_ir_h2rcp_int(int); +extern "C" int __hip_hc_ir_h2rsqrt_int(int); +extern "C" int __hip_hc_ir_h2sin_int(int); +extern "C" int __hip_hc_ir_h2sqrt_int(int); +extern "C" int __hip_hc_ir_h2trunc_int(int); + +/* + Half2 Arithmetic Functions +*/ + +__device__ static inline __half2 __hadd2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hadd2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hadd2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hadd2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hfma2(__half2 a, __half2 b, __half2 c) { + __half2 d; + d.q = __hip_hc_ir_hfma2_int(a.q, b.q, c.q); + return d; +} + +__device__ static inline __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c) { + __half2 d; + d.q = __hip_hc_ir_hfma2_int(a.q, b.q, c.q); + return d; +} + +__device__ static inline __half2 __hmul2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hmul2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hmul2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hmul2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hsub2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hsub2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hneg2(__half2 a) { + __half2 c; + c.p[0] = - a.p[0]; + c.p[1] = - a.p[1]; + return c; +} + +__device__ static inline __half2 __hsub2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hsub2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 h2div(__half2 a, __half2 b) { + __half2 c; + c.p[0] = a.p[0] / b.p[0]; + c.p[1] = a.p[1] / b.p[1]; + return c; +} + + +__device__ static inline __half hceil(const __half h) { + return __hip_hc_ir_hceil_half(h); +} + +__device__ static inline __half hcos(const __half h) { + return __hip_hc_ir_hcos_half(h); +} + +__device__ static inline __half hexp(const __half h) { + return __hip_hc_ir_hexp2_half(__hmul(h, 1.442694)); +} + +__device__ static inline __half hexp10(const __half h) { + return __hip_hc_ir_hexp2_half(__hmul(h, 3.3219281)); +} + +__device__ static inline __half hexp2(const __half h) { + return __hip_hc_ir_hexp2_half(h); +} + +__device__ static inline __half hfloor(const __half h) { + return __hip_hc_ir_hfloor_half(h); +} + +__device__ static inline __half hlog(const __half h) { + return __hmul(__hip_hc_ir_hlog2_half(h), 0.693147); +} + +__device__ static inline __half hlog10(const __half h) { + return __hmul(__hip_hc_ir_hlog2_half(h), 0.301029); +} + +__device__ static inline __half hlog2(const __half h) { + return __hip_hc_ir_hlog2_half(h); +} +/* +__device__ static inline __half hrcp(const __half h) { + return __hip_hc_ir_hrcp_half(h); +} +*/ +__device__ static inline __half hrint(const __half h) { + return __hip_hc_ir_hrint_half(h); +} + +__device__ static inline __half hrsqrt(const __half h) { + return __hip_hc_ir_hrsqrt_half(h); +} + +__device__ static inline __half hsin(const __half h) { + return __hip_hc_ir_hsin_half(h); +} + +__device__ static inline __half hsqrt(const __half a) { + return __hip_hc_ir_hsqrt_half(a); +} + +__device__ static inline __half htrunc(const __half a) { + return __hip_hc_ir_htrunc_half(a); +} + +/* +Half2 Math Operations +*/ + +__device__ static inline __half2 h2ceil(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2ceil_int(h.q); + return a; +} + +__device__ static inline __half2 h2cos(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2cos_int(h.q); + return a; +} + +__device__ static inline __half2 h2exp(const __half2 h) { + __half2 factor; + factor.p[0] = 1.442694; + factor.p[1] = 1.442694; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + +__device__ static inline __half2 h2exp10(const __half2 h) { + __half2 factor; + factor.p[0] = 3.3219281; + factor.p[1] = 3.3219281; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + +__device__ static inline __half2 h2exp2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2exp2_int(h.q); + return a; +} + +__device__ static inline __half2 h2floor(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2floor_int(h.q); + return a; +} + +__device__ static inline __half2 h2log(const __half2 h) { + __half2 factor; + factor.p[0] = 0.693147; + factor.p[1] = 0.693147; + factor. q = __hip_hc_ir_hmul2_int(__hip_hc_ir_h2log2_int(h.q), factor.q); + return factor; +} + +__device__ static inline __half2 h2log10(const __half2 h) { + __half2 factor; + factor.p[0] = 0.301029; + factor.p[1] = 0.301029; + factor.q = __hip_hc_ir_hmul2_int(__hip_hc_ir_h2log2_int(h.q), factor.q); + return factor; +} +__device__ static inline __half2 h2log2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2log2_int(h.q); + return a; +} + +__device__ static inline __half2 h2rcp(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2rcp_int(h.q); + return a; +} + +__device__ static inline __half2 h2rsqrt(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2rsqrt_int(h.q); + return a; +} + +__device__ static inline __half2 h2sin(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2sin_int(h.q); + return a; +} + +__device__ static inline __half2 h2sqrt(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2sqrt_int(h.q); + return a; +} + +__device__ static inline __half2 h2trunc(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2trunc_int(h.q); + return a; +} + +#endif + +#if __clang_major__ == 3 + +typedef struct { + unsigned x: 16; +} __half; + +typedef struct __attribute__((aligned(4))){ + union { + __half p[2]; + unsigned int q; + }; +} __half2; + + +#endif + #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_hcc.h b/projects/hip/include/hip/hcc_detail/hip_hcc.h new file mode 100644 index 0000000000..fc04917931 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/hip_hcc.h @@ -0,0 +1,103 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_HCC_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_HCC_H + +#include "hip/hip_runtime_api.h" + +#if __cplusplus +#ifdef __HCC__ +#include + + +/** + *------------------------------------------------------------------------------------------------- + *------------------------------------------------------------------------------------------------- + * @defgroup HCC-specific features + * @warning These APIs provide access to special features of HCC compiler and are not available through the CUDA path. + * @{ + */ + + +/** + * @brief Return hc::accelerator associated with the specified deviceId + * @return #hipSuccess, #hipErrorInvalidDevice + */ +hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); + +/** + * @brief Return hc::accelerator_view associated with the specified stream + * + * If stream is 0, the accelerator_view for the default stream is returned. + * @return #hipSuccess + */ +hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); + + +#endif // #ifdef __HCC__ + +/** + * @brief launches kernel f with launch parameters and shared memory on stream with arguments passed to kernelparams or extra + * + * @param [in[ f Kernel to launch. + * @param [in] gridDimX X grid dimension specified in work-items + * @param [in] gridDimY Y grid dimension specified in work-items + * @param [in] gridDimZ Z grid dimension specified in work-items + * @param [in] blockDimX X block dimensions specified in work-items + * @param [in] blockDimY Y grid dimension specified in work-items + * @param [in] blockDimZ Z grid dimension specified in work-items + * @param [in] sharedMemBytes Amount of dynamic shared memory to allocate for this kernel. The kernel can access this with HIP_DYNAMIC_SHARED. + * @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules. + * @param [in] kernelParams + * @param [in] extra Pointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. + * @param [in] startEvent If non-null, specified event will be updated to track the start time of the kernel launch. The event must be created before calling this API. + * @param [in] stopEvent If non-null, specified event will be updated to track the stop time of the kernel launch. The event must be created before calling this API. + * + * @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue + * + * @warning kernellParams argument is not yet implemented in HIP. Please use extra instead. Please refer to hip_porting_driver_api.md for sample usage. + + * HIP/ROCm actually updates the start event when the associated kernel completes. + */ +hipError_t hipHccModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, + uint32_t globalWorkSizeY, + uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, + uint32_t localWorkSizeY, + uint32_t localWorkSizeZ, + size_t sharedMemBytes, + hipStream_t hStream, + void **kernelParams, + void **extra, + hipEvent_t startEvent=nullptr, + hipEvent_t stopEvent=nullptr + ); + +// doxygen end HCC-specific features +/** + * @} + */ +#endif // #if __cplusplus + +#endif // diff --git a/projects/hip/include/hip/hcc_detail/hip_ldg.h b/projects/hip/include/hip/hcc_detail/hip_ldg.h index 7dd6451749..473e70b4cb 100644 --- a/projects/hip/include/hip/hcc_detail/hip_ldg.h +++ b/projects/hip/include/hip/hcc_detail/hip_ldg.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,14 +20,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_LDG_H -#define HIP_LDG_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H -#if __HCC__ +#if defined __HCC__ #if __hcc_workweek__ >= 16164 -#include "hip/hip_vector_types.h" -#include "hip/hcc_detail/host_defines.h" - +#include "hip_vector_types.h" +#include "host_defines.h" __device__ char __ldg(const char* ); __device__ char2 __ldg(const char2* ); @@ -75,4 +74,3 @@ __device__ double2 __ldg(const double2* ); #endif // __HCC__ #endif // HIP_LDG_H - diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 78accc0c5b..06ce65bc9a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,13 +26,12 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_H -#define HIP_RUNTIME_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H //--- // Top part of file can be compiled with any compiler - //#include #if __cplusplus #include @@ -40,39 +39,77 @@ THE SOFTWARE. #include #include #include -#endif +#endif//__cplusplus + // Define NVCC_COMPAT for CUDA compatibility #define NVCC_COMPAT #define CUDA_SUCCESS hipSuccess #include -//#include "hip/hcc_detail/hip_hcc.h" + + +#if USE_PROMOTE_FREE_HCC == 1 +#define ADDRESS_SPACE_1 +#define ADDRESS_SPACE_3 +#else +#define ADDRESS_SPACE_1 __attribute__((address_space(1))) +#define ADDRESS_SPACE_3 __attribute__((address_space(3))) +#endif + //--- // Remainder of this file only compiles with HCC -#ifdef __HCC__ +#if defined __HCC__ #include +//TODO-HCC-GL - change this to typedef. +//typedef grid_launch_parm hipLaunchParm ; -#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) -// Use field names for grid_launch 2.0 structure, if HCC supports GL 2.0. +#if GENERIC_GRID_LAUNCH == 0 + #define hipLaunchParm grid_launch_parm #else +namespace hip_impl +{ + struct Empty_launch_parm {}; +} +#define hipLaunchParm hip_impl::Empty_launch_parm +#endif //GENERIC_GRID_LAUNCH + +#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) || GENERIC_GRID_LAUNCH == 1 +#else // Use field names for grid_launch 2.0 structure, if HCC supports GL 2.0. #error (HCC must support GRID_LAUNCH_20) -#endif +#endif //GRID_LAUNCH_VERSION + +#endif //HCC + +#if GENERIC_GRID_LAUNCH==1 && defined __HCC__ +#include "grid_launch_GGL.hpp" +#endif//GENERIC_GRID_LAUNCH extern int HIP_TRACE_API; -//TODO-HCC-GL - change this to typedef. -//typedef grid_launch_parm hipLaunchParm ; -#define hipLaunchParm grid_launch_parm #ifdef __cplusplus //#include #include #endif #include +#include +#include + // TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define. #if defined (__KALMAR_ACCELERATOR__) && !defined (__HCC_ACCELERATOR__) #define __HCC_ACCELERATOR__ __KALMAR_ACCELERATOR__ #endif + + + +// TODO-HCC add a dummy implementation of assert, need to replace with a proper kernel exit call. +#if __HIP_DEVICE_COMPILE__ == 1 + #undef assert + #define assert(COND) { if (COND) {} } +#endif + + + // Feature tests: #if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) // Device compile and not host compile: @@ -120,210 +157,9 @@ extern int HIP_TRACE_API; #define __HCC_C__ #endif -__device__ float acosf(float x); -__device__ float acoshf(float x); -__device__ float asinf(float x); -__device__ float asinhf(float x); -__device__ float atan2f(float y, float x); -__device__ float atanf(float x); -__device__ float atanhf(float x); -__device__ float cbrtf(float x); -__device__ float ceilf(float x); -__device__ float copysignf(float x, float y); -__device__ float coshf(float x); -__device__ float cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); -__device__ float erfcf(float x); -__device__ float erfcinvf(float y); -__host__ float erfcinvf(float y); -__device__ float erfcxf(float x); -__host__ float erfcxf(float x); -__device__ float erff(float x); -__device__ float erfinvf(float y); -__host__ float erfinvf(float y); -__device__ float exp2f(float x); -__device__ float expm1f(float x); -__device__ float fabsf(float x); -__device__ float fdimf(float x, float y); -__device__ __host__ float fdividef(float x, float y); -__device__ float floorf(float x); -__device__ float fmaf(float x, float y, float z); -__device__ float fmaxf(float x, float y); -__device__ float fminf(float x, float y); -__device__ float fmodf(float x, float y); -__device__ float frexpf(float x, float y); -__device__ float hypotf(float x, float y); -__device__ float ilogbf(float x); -__host__ __device__ unsigned isfinite(float a); -__device__ unsigned isinf(float a); -__device__ unsigned isnan(float a); -__device__ float j0f(float x); -__device__ float j1f(float x); -__device__ float jnf(int n, float x); -__device__ float ldexpf(float x, int exp); -__device__ float lgammaf(float x); -__device__ long long int llrintf(float x); -__device__ long long int llroundf(float x); -__device__ float log1pf(float x); -__device__ float logbf(float x); -__device__ long int lrintf(float x); -__device__ long int lroundf(float x); -__device__ float modff(float x, float *iptr); -__device__ float nanf(const char* tagp); -__device__ float nearbyintf(float x); -__device__ float nextafterf(float x, float y); -__device__ float norm3df(float a, float b, float c); -__host__ float norm3df(float a, float b, float c); -__device__ float norm4df(float a, float b, float c, float d); -__host__ float norm4df(float a, float b, float c, float d); -__device__ float normcdff(float y); -__host__ float normcdff(float y); -__device__ float normcdfinvf(float y); -__host__ float normcdfinvf(float y); -__device__ float normf(int dim, const float *a); -__device__ float rcbrtf(float x); -__host__ float rcbrtf(float x); -__device__ float remainderf(float x, float y); -__device__ float remquof(float x, float y, int *quo); -__device__ float rhypotf(float x, float y); -__host__ float rhypotf(float x, float y); -__device__ float rintf(float x); -__device__ float rnorm3df(float a, float b, float c); -__host__ float rnorm3df(float a, float b, float c); -__device__ float rnorm4df(float a, float b, float c, float d); -__host__ float rnorm4df(float a, float b, float c, float d); -__device__ float rnormf(int dim, const float* a); -__host__ float rnormf(int dim, const float* a); -__device__ float roundf(float x); -__device__ float rsqrtf(float x); -__device__ float scalblnf(float x, long int n); -__device__ float scalbnf(float x, int n); -__host__ __device__ unsigned signbit(float a); -__device__ void sincospif(float x, float *sptr, float *cptr); -__host__ void sincospif(float x, float *sptr, float *cptr); -__device__ float sinhf(float x); -__device__ float sinpif(float x); -__device__ float sqrtf(float x); -__device__ float tanhf(float x); -__device__ float tgammaf(float x); -__device__ float truncf(float x); -__device__ float y0f(float x); -__device__ float y1f(float x); -__device__ float ynf(int n, float x); - -__host__ __device__ float cospif(float x); -__host__ __device__ float sinpif(float x); -__device__ float sqrtf(float x); -__host__ __device__ float rsqrtf(float x); - -__device__ double acos(double x); -__device__ double acosh(double x); -__device__ double asin(double x); -__device__ double asinh(double x); -__device__ double atan(double x); -__device__ double atan2(double y, double x); -__device__ double atanh(double x); -__device__ double cbrt(double x); -__device__ double ceil(double x); -__device__ double copysign(double x, double y); -__device__ double cos(double x); -__device__ double cosh(double x); -__host__ __device__ double cospi(double x); -__device__ double cyl_bessel_i0(double x); -__device__ double cyl_bessel_i1(double x); -__device__ double erf(double x); -__device__ double erfc(double x); -__device__ double erfcinv(double y); -__device__ double erfcx(double x); -__device__ double erfinv(double x); -__device__ double exp(double x); -__device__ double exp10(double x); -__device__ double exp2(double x); -__device__ double expm1(double x); -__device__ double fabs(double x); -__device__ double fdim(double x, double y); -__device__ double fdivide(double x, double y); -__device__ double floor(double x); -__device__ double fma(double x, double y, double z); -__device__ double fmax(double x, double y); -__device__ double fmin(double x, double y); -__device__ double fmod(double x, double y); -__device__ double frexp(double x, int *nptr); -__device__ double hypot(double x, double y); -__device__ double ilogb(double x); -__host__ __device__ unsigned isfinite(double x); -__device__ unsigned isinf(double x); -__device__ unsigned isnan(double x); -__device__ double j0(double x); -__device__ double j1(double x); -__device__ double jn(int n, double x); -__device__ double ldexp(double x, int exp); -__device__ double lgamma(double x); -__device__ long long llrint(double x); -__device__ long long llround(double x); -__device__ double log(double x); -__device__ double log10(double x); -__device__ double log1p(double x); -__device__ double log2(double x); -__device__ double logb(double x); -__device__ long int lrint(double x); -__device__ long int lround(double x); -__device__ double modf(double x, double *iptr); -__device__ double nan(const char* tagp); -__device__ double nearbyint(double x); -__device__ double nextafter(double x, double y); -__device__ double norm(int dim, const double* t); -__device__ double norm3d(double a, double b, double c); -__host__ double norm3d(double a, double b, double c); -__device__ double norm4d(double a, double b, double c, double d); -__host__ double norm4d(double a, double b, double c, double d); -__device__ double normcdf(double y); -__host__ double normcdf(double y); -__device__ double normcdfinv(double y); -__host__ double normcdfinv(double y); -__device__ double pow(double x, double y); -__device__ double rcbrt(double x); -__host__ double rcbrt(double x); -__device__ double remainder(double x, double y); -__device__ double remquo(double x, double y, int *quo); -__device__ double rhypot(double x, double y); -__host__ double rhypot(double x, double y); -__device__ double rint(double x); -__device__ double rnorm(int dim, const double* t); -__host__ double rnorm(int dim, const double* t); -__device__ double rnorm3d(double a, double b, double c); -__host__ double rnorm3d(double a, double b, double c); -__device__ double rnorm4d(double a, double b, double c, double d); -__host__ double rnorm4d(double a, double b, double c, double d); -__device__ double round(double x); -__host__ __device__ double rsqrt(double x); -__device__ double scalbln(double x, long int n); -__device__ double scalbn(double x, int n); -__host__ __device__ unsigned signbit(double a); -__device__ double sin(double a); -__device__ void sincos(double x, double *sptr, double *cptr); -__device__ void sincospi(double x, double *sptr, double *cptr); -__host__ void sincospi(double x, double *sptr, double *cptr); -__device__ double sinh(double x); -__host__ __device__ double sinpi(double x); -__device__ double sqrt(double x); -__device__ double tan(double x); -__device__ double tanh(double x); -__device__ double tgamma(double x); -__device__ double trunc(double x); -__device__ double y0(double x); -__device__ double y1(double y); -__device__ double yn(int n, double x); - -__host__ double erfcinv(double y); -__host__ double erfcx(double x); -__host__ double erfinv(double y); -__host__ double fdivide(double x, double y); - // TODO - hipify-clang - change to use the function call. //#define warpSize hc::__wavesize() -extern const int warpSize; - +static constexpr int warpSize = 64; #define clock_t long long int __device__ long long int clock64(); @@ -417,30 +253,13 @@ __device__ unsigned int atomicInc(unsigned int* address, __device__ unsigned int atomicDec(unsigned int* address, unsigned int val); -//__mul24 __umul24 -__device__ int __mul24(int arg1, int arg2); -__device__ unsigned int __umul24(unsigned int arg1, unsigned int arg2); - -// integer intrinsic function __poc __clz __ffs __brev -__device__ unsigned int __popc( unsigned int input); -__device__ unsigned int __popcll( unsigned long long int input); -__device__ unsigned int __clz(unsigned int input); -__device__ unsigned int __clzll(unsigned long long int input); -__device__ unsigned int __clz(int input); -__device__ unsigned int __clzll(long long int input); -__device__ unsigned int __ffs(unsigned int input); -__device__ unsigned int __ffsll(unsigned long long int input); -__device__ unsigned int __ffs(int input); -__device__ unsigned int __ffsll(long long int input); -__device__ unsigned int __brev( unsigned int input); -__device__ unsigned long long int __brevll( unsigned long long int input); - - -// warp vote function __all __any __ballot + // warp vote function __all __any __ballot __device__ int __all( int input); __device__ int __any( int input); __device__ unsigned long long int __ballot( int input); +#if __HIP_ARCH_GFX701__ == 0 + // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); @@ -460,259 +279,25 @@ __device__ float __shfl(float input, int lane, int width); __device__ float __shfl_up(float input, unsigned int lane_delta, int width); __device__ float __shfl_down(float input, unsigned int lane_delta, int width); __device__ float __shfl_xor(float input, int lane_mask, int width); -#endif +#endif //__cplusplus + +__device__ unsigned __hip_ds_bpermute(int index, unsigned src); +__device__ float __hip_ds_bpermutef(int index, float src); +__device__ unsigned __hip_ds_permute(int index, unsigned src); +__device__ float __hip_ds_permutef(int index, float src); + +__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern); +__device__ float __hip_ds_swizzlef(float src, int pattern); + +__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl); + +#endif //__HIP_ARCH_GFX803__ == 1 __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); -__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); +__device__ ADDRESS_SPACE_3 void* __get_dynamicgroupbaseptr(); -//TODO - add a couple fast math operations here, the set here will grow : - -// Single Precision Precise Math -__device__ float __hip_precise_cosf(float); -__device__ float __hip_precise_exp10f(float); -__device__ float __hip_precise_expf(float); -__device__ float __hip_precise_frsqrt_rn(float); -__device__ float __hip_precise_fsqrt_rd(float); -__device__ float __hip_precise_fsqrt_rn(float); -__device__ float __hip_precise_fsqrt_ru(float); -__device__ float __hip_precise_fsqrt_rz(float); -__device__ float __hip_precise_log10f(float); -__device__ float __hip_precise_log2f(float); -__device__ float __hip_precise_logf(float); -__device__ float __hip_precise_powf(float, float); -__device__ void __hip_precise_sincosf(float,float*,float*); -__device__ float __hip_precise_sinf(float); -__device__ float __hip_precise_tanf(float); - -// Double Precision Precise Math -__device__ double __hip_precise_dsqrt_rd(double); -__device__ double __hip_precise_dsqrt_rn(double); -__device__ double __hip_precise_dsqrt_ru(double); -__device__ double __hip_precise_dsqrt_rz(double); - -// Single Precision Fast Math -extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); -extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); -__device__ float __hip_fast_exp10f(float); -__device__ float __hip_fast_expf(float); -__device__ float __hip_fast_frsqrt_rn(float); -extern __attribute__((const)) float __hip_fast_fsqrt_rd(float) __asm("llvm.sqrt.f32"); -__device__ float __hip_fast_fsqrt_rn(float); -__device__ float __hip_fast_fsqrt_ru(float); -__device__ float __hip_fast_fsqrt_rz(float); -__device__ float __hip_fast_log10f(float); -extern __attribute__((const)) float __hip_fast_log2f(float) __asm("llvm.log2.f32"); -__device__ float __hip_fast_logf(float); -__device__ float __hip_fast_powf(float, float); -__device__ void __hip_fast_sincosf(float,float*,float*); -extern __attribute__((const)) float __hip_fast_sinf(float) __asm("llvm.sin.f32"); -__device__ float __hip_fast_tanf(float); -extern __attribute__((const)) float __hip_fast_fmaf(float,float,float) __asm("llvm.fma.f32"); -extern __attribute__((const)) float __hip_fast_frcp(float) __asm("llvm.amdgcn.rcp.f32"); - -extern __attribute__((const)) double __hip_fast_dsqrt(double) __asm("llvm.sqrt.f64"); -extern __attribute__((const)) double __hip_fast_fma(double,double,double) __asm("llvm.fma.f64"); -extern __attribute__((const)) double __hip_fast_drcp(double) __asm("llvm.amdgcn.rcp.f64"); - -#ifdef HIP_FAST_MATH -// Single Precision Precise Math when enabled - -__device__ inline float cosf(float x) { - return __hip_fast_cosf(x); -} - -__device__ inline float exp10f(float x) { - return __hip_fast_exp10f(x); -} - -__device__ inline float expf(float x) { - return __hip_fast_expf(x); -} - -__device__ inline float log10f(float x) { - return __hip_fast_log10f(x); -} - -__device__ inline float log2f(float x) { - return __hip_fast_log2f(x); -} - -__device__ inline float logf(float x) { - return __hip_fast_logf(x); -} - -__device__ inline float powf(float base, float exponent) { - return __hip_fast_powf(base, exponent); -} - -__device__ inline void sincosf(float x, float *s, float *c) { - return __hip_fast_sincosf(x, s, c); -} - -__device__ inline float sinf(float x) { - return __hip_fast_sinf(x); -} - -__device__ inline float tanf(float x) { - return __hip_fast_tanf(x); -} - -#else - -__device__ float sinf(float); -__device__ float cosf(float); -__device__ float tanf(float); -__device__ void sincosf(float, float*, float*); -__device__ float logf(float); -__device__ float log2f(float); -__device__ float log10f(float); -__device__ float expf(float); -__device__ float exp10f(float); -__device__ float powf(float, float); - -#endif -// Single Precision Fast Math -__device__ inline float __cosf(float x) { - return __hip_fast_cosf(x); -} - -__device__ inline float __exp10f(float x) { - return __hip_fast_exp10f(x); -} - -__device__ inline float __expf(float x) { - return __hip_fast_expf(x); -} - -__device__ inline float __frsqrt_rn(float x) { - return __hip_fast_frsqrt_rn(x); -} - -__device__ inline float __fsqrt_rd(float x) { - return __hip_fast_fsqrt_rd(x); -} - -__device__ inline float __fsqrt_rn(float x) { - return __hip_fast_fsqrt_rn(x); -} - -__device__ inline float __fsqrt_ru(float x) { - return __hip_fast_fsqrt_ru(x); -} - -__device__ inline float __fsqrt_rz(float x) { - return __hip_fast_fsqrt_rz(x); -} - -__device__ inline float __log10f(float x) { - return __hip_fast_log10f(x); -} - -__device__ inline float __log2f(float x) { - return __hip_fast_log2f(x); -} - -__device__ inline float __logf(float x) { - return __hip_fast_logf(x); -} - -__device__ inline float __powf(float base, float exponent) { - return __hip_fast_powf(base, exponent); -} - -__device__ inline void __sincosf(float x, float *s, float *c) { - return __hip_fast_sincosf(x, s, c); -} - -__device__ inline float __sinf(float x) { - return __hip_fast_sinf(x); -} - -__device__ inline float __tanf(float x) { - return __hip_fast_tanf(x); -} - -__device__ inline float __fmaf_rd(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_rn(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_ru(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_rz(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __frcp_rd(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_rn(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_ru(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_rz(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline double __dsqrt_rd(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_rn(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_ru(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_rz(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __fma_rd(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rn(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_ru(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rz(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __drcp_rd(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_rn(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_ru(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_rz(double x) { - return __hip_fast_drcp(x); -} /** * CUDA 8 device function features @@ -738,6 +323,10 @@ __device__ inline double __drcp_rz(double x) { * On AMD platforms, the threadfence* routines are currently empty stubs. */ +extern __attribute__((const)) __device__ void __hip_hc_threadfence() __asm("__llvm_fence_sc_dev"); +extern __attribute__((const)) __device__ void __hip_hc_threadfence_block() __asm("__llvm_fence_sc_wg"); + + /** * @brief threadfence_block makes writes visible to threads running in same block. * @@ -748,7 +337,9 @@ __device__ inline double __drcp_rz(double x) { * @warning __threadfence_block is a stub and map to no-op. */ // __device__ void __threadfence_block(void); -extern "C" __device__ void __threadfence_block(void); +__device__ static inline void __threadfence_block(void) { + return __hip_hc_threadfence_block(); +} /** * @brief threadfence makes wirtes visible to other threads running on same GPU. @@ -760,7 +351,9 @@ extern "C" __device__ void __threadfence_block(void); * @warning __threadfence is a stub and map to no-op, application should set "export HSA_DISABLE_CACHE=1" to disable both L1 and L2 caches. */ // __device__ void __threadfence(void) __attribute__((deprecated("Provided for compile-time compatibility, not yet functional"))); -extern "C" __device__ void __threadfence(void); +__device__ static inline void __threadfence(void) { + return __hip_hc_threadfence(); +} /** * @brief threadfence_system makes writes to pinned system memory visible on host CPU. @@ -774,16 +367,6 @@ extern "C" __device__ void __threadfence(void); //__device__ void __threadfence_system(void) __attribute__((deprecated("Provided with workaround configuration, see hip_kernel_language.md for details"))); __device__ void __threadfence_system(void) ; -__device__ unsigned __hip_ds_bpermute(int index, unsigned src); -__device__ float __hip_ds_bpermutef(int index, float src); -__device__ unsigned __hip_ds_permute(int index, unsigned src); -__device__ float __hip_ds_permutef(int index, float src); - -__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern); -__device__ float __hip_ds_swizzlef(float src, int pattern); - -__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl); - // doxygen end Fence Fence /** * @} @@ -806,32 +389,48 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask #define hipGridDim_y (hc_get_num_groups(1)) #define hipGridDim_z (hc_get_num_groups(2)) -//extern "C" __device__ void* memcpy(void* dst, void* src, size_t size); -//extern "C" __device__ void* memset(void* ptr, uint8_t val, size_t size); - +extern "C" __device__ void* __hip_hc_memcpy(void* dst, const void* src, size_t size); +extern "C" __device__ void* __hip_hc_memset(void* ptr, uint8_t val, size_t size); extern "C" __device__ void* __hip_hc_malloc(size_t); extern "C" __device__ void* __hip_hc_free(void *ptr); -//extern "C" __device__ void* malloc(size_t size); -//extern "C" __device__ void* free(void *ptr); +static inline __device__ void* malloc(size_t size) +{ + return __hip_hc_malloc(size); +} + +static inline __device__ void* free(void *ptr) +{ + return __hip_hc_free(ptr); +} + +static inline __device__ void* memcpy(void* dst, const void* src, size_t size) +{ + return __hip_hc_memcpy(dst, src, size); +} + +static inline __device__ void* memset(void* ptr, int val, size_t size) +{ + uint8_t val8 = static_cast (val); + return __hip_hc_memset(ptr, val8, size); +} + -extern "C" __device__ char4 __hip_hc_add8pk(char4, char4); -extern "C" __device__ char4 __hip_hc_sub8pk(char4, char4); -extern "C" __device__ char4 __hip_hc_mul8pk(char4, char4); #define __syncthreads() hc_barrier(CLK_LOCAL_MEM_FENCE) -#define HIP_KERNEL_NAME(...) __VA_ARGS__ +#define HIP_KERNEL_NAME(...) (__VA_ARGS__) #define HIP_SYMBOL(X) #X -#ifdef __HCC_CPP__ +#if defined __HCC_CPP__ extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launch_parm &lp); - +#if GENERIC_GRID_LAUNCH == 0 +//#warning "Original hipLaunchKernel defined" // Due to multiple overloaded versions of ihipPreLaunchKernel, the numBlocks3D and blockDim3D can be either size_t or dim3 types #define hipLaunchKernel(_kernelName, _numBlocks3D, _blockDim3D, _groupMemBytes, _stream, ...) \ do {\ @@ -841,13 +440,13 @@ do {\ _kernelName (lp, ##__VA_ARGS__);\ ihipPostLaunchKernel(#_kernelName, trueStream, lp);\ } while(0) - +#endif //GENERIC_GRID_LAUNCH #elif defined (__HCC_C__) //TODO - develop C interface. -#endif +#endif //__HCC_CPP__ /** * extern __shared__ @@ -856,12 +455,11 @@ do {\ // Macro to replace extern __shared__ declarations // to local variable definitions #define HIP_DYNAMIC_SHARED(type, var) \ - __attribute__((address_space(3))) type* var = \ - (__attribute__((address_space(3))) type*)__get_dynamicgroupbaseptr(); \ + ADDRESS_SPACE_3 type* var = \ + (ADDRESS_SPACE_3 type*)__get_dynamicgroupbaseptr(); \ -#define HIP_DYNAMIC_SHARED_ATTRIBUTE __attribute__((address_space(3))) +#define HIP_DYNAMIC_SHARED_ATTRIBUTE ADDRESS_SPACE_3 -#endif // __HCC__ /** @@ -885,4 +483,4 @@ do {\ -#endif +#endif//HIP_HCC_DETAIL_RUNTIME_H diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 52e59ed17a..7a99ff0810 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,19 +21,23 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_API_H -#define HIP_RUNTIME_API_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H /** * @file hcc_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. */ - #include #include +#include + +#ifndef GENERIC_GRID_LAUNCH +#define GENERIC_GRID_LAUNCH 1 +#endif #include #include -//#include "hip/hip_hcc.h" +#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); @@ -53,7 +57,7 @@ extern "C" { typedef struct ihipCtx_t *hipCtx_t; // Note many APIs also use integer deviceIds as an alternative to the device pointer: -typedef struct ihipDevice_t *hipDevice_t; +typedef int hipDevice_t; typedef struct ihipStream_t *hipStream_t; @@ -61,7 +65,12 @@ typedef struct ihipStream_t *hipStream_t; #define hipIpcMemLazyEnablePeerAccess 0 -typedef struct ihipIpcMemHandle_t *hipIpcMemHandle_t; +#define HIP_IPC_HANDLE_SIZE 64 + +typedef struct hipIpcMemHandle_st +{ + char reserved[HIP_IPC_HANDLE_SIZE]; +}hipIpcMemHandle_t; //TODO: IPC event handle currently unsupported struct ihipIpcEventHandle_t; @@ -72,7 +81,7 @@ typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; typedef struct ihipModule_t *hipModule_t; -typedef struct ihipFunction_t *hipFunction_t; +typedef struct ihipModuleSymbol_t *hipFunction_t; typedef void* hipDeviceptr_t; @@ -170,6 +179,12 @@ typedef enum hipMemcpyKind { ,hipMemcpyDefault = 4, ///< Runtime will automatically determine copy-kind based on virtual addresses. } hipMemcpyKind; +typedef struct { + unsigned int width; + unsigned int height; + enum hipChannelFormatKind f; + void* data; //FIXME: generalize this +} hipArray; @@ -358,7 +373,7 @@ hipError_t hipDeviceGetCacheConfig ( hipFuncCache_t *cacheConfig ); * Note: Currently, only hipLimitMallocHeapSize is available * */ -hipError_t hipDeviceGetLimit(size_t *pValue, hipLimit_t limit); +hipError_t hipDeviceGetLimit(size_t *pValue, enum hipLimit_t limit); /** @@ -504,12 +519,10 @@ const char *hipGetErrorString(hipError_t hipError); * @{ * * The following Stream APIs are not (yet) supported in HIP: - * - cudaStreamAddCallback * - cudaStreamAttachMemAsync * - cudaStreamCreateWithPriority * - cudaStreamGetPriority - * - cudaStreamWaitEvent - */ + */ /** @@ -840,7 +853,7 @@ hipError_t hipEventQuery(hipEvent_t event) ; * * @see hipGetDeviceCount, hipGetDevice, hipSetDevice, hipChooseDevice */ -hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr); +hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void* ptr); /** * @brief Allocate memory on the default accelerator @@ -848,7 +861,9 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) * @param[out] ptr Pointer to the allocated memory * @param[in] size Requested memory size * - * @return #hipSuccess + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * + * @return #hipSuccess, #hipErrorMemoryAllocation, #hipErrorInvalidValue (bad context, null *ptr) * * @see hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc */ @@ -860,6 +875,8 @@ hipError_t hipMalloc(void** ptr, size_t size) ; * @param[out] ptr Pointer to the allocated host pinned memory * @param[in] size Requested memory size * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @deprecated use hipHostMalloc() instead @@ -873,6 +890,8 @@ hipError_t hipMallocHost(void** ptr, size_t size) __attribute__((deprecated("use * @param[in] size Requested memory size * @param[in] flags Type of host memory allocation * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @see hipSetDeviceFlags, hipHostFree @@ -886,6 +905,8 @@ hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags) ; * @param[in] size Requested memory size * @param[in] flags Type of host memory allocation * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @deprecated use hipHostMalloc() instead @@ -970,6 +991,9 @@ hipError_t hipHostUnregister(void* hostPtr) ; * @param[out] pitch Pitch for allocation (in bytes) * @param[in] width Requested pitched allocation width (in bytes) * @param[in] height Requested pitched allocation height + * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return Error code * * @see hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc @@ -1132,7 +1156,7 @@ hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t siz * * @see hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync */ -hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind); +hipError_t hipMemcpyToSymbol(const void* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind); /** @@ -1152,9 +1176,11 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t siz * * @see hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync */ -hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); +hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); +hipError_t hipMemcpyFromSymbol(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind); +hipError_t hipMemcpyFromSymbolAsync(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); /** * @brief Copy data from src to dst asynchronously. @@ -1185,19 +1211,24 @@ hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcp #endif /** - * @brief Copy data from src to dst asynchronously. + * @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. * - * It supports memory from host to device, - * device to host, device to device and host to host. - * - * @param[out] dst Data being copy to - * @param[in] src Data being copy from + * @param[out] dst Data being filled + * @param[in] constant value to be set * @param[in] sizeBytes Data size in bytes - * @param[in] accelerator_view Accelerator view which the copy is being enqueued - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized */ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ); +/** + * @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. + * + * @param[out] dst Data ptr to be filled + * @param[in] constant value to be set + * @param[in] sizeBytes Data size in bytes + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized + */ +hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes ); /** * @brief Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value value. @@ -1228,6 +1259,91 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st **/ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; + +hipError_t hipMemPtrGetInfo(void *ptr, size_t *size); + + +/** + * @brief Allocate an array on the device. + * + * @param[out] array Pointer to allocated array in device memory + * @param[in] desc Requested channel format + * @param[in] width Requested array allocation width + * @param[in] height Requested array allocation height + * @param[in] flags Requested properties of allocated array + * @return #hipSuccess, #hipErrorMemoryAllocation + * + * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree + */ +#if __cplusplus +hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, + size_t width, size_t height = 0, unsigned int flags = 0); +#else +hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* desc, + size_t width, size_t height, unsigned int flags); +#endif +/** + * @brief Frees an array on the device. + * + * @param[in] array Pointer to array to free + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError + * + * @see hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree + */ +hipError_t hipFreeArray(hipArray* array); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, + size_t spitch, size_t width, size_t height, hipMemcpyKind kind); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, + const void* src, size_t count, hipMemcpyKind kind); + + + // doxygen end Memory /** * @} @@ -1580,6 +1696,66 @@ hipError_t hipCtxEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags); */ hipError_t hipCtxDisablePeerAccess (hipCtx_t peerCtx); +/** + * @brief Get the state of the primary context. + * + * @param [in] Device to get primary context flags for + * @param [out] Pointer to store flags + * @param [out] Pointer to store context state; 0 = inactive, 1 = active + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ); + +/** + * @brief Release the primary context on the GPU. + * + * @param [in] Device which primary context is released + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + * @warning This function return #hipSuccess though doesn't release the primaryCtx by design on HIP/HCC path. + */ +hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev); + +/** + * @brief Retain the primary context on the GPU. + * + * @param [out] Returned context handle of the new context + * @param [in] Device which primary context is released + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ); + +/** + * @brief Resets the primary context on the GPU. + * + * @param [in] Device which primary context is reset + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ); + +/** + * @brief Set flags for the primary context. + * + * @param [in] Device for which the primary context flags are set + * @param [in] New flags for the device + * + * @returns #hipSuccess, #hipErrorContextAlreadyInUse + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ); + // doxygen end Context Management /** * @} @@ -1737,19 +1913,18 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image); /** * @brief launches kernel f with launch parameters and shared memory on stream with arguments passed to kernelparams or extra * - * @param [in[ f - * @param [in] gridDimX - * @param [in] gridDimY - * @param [in] gridDimZ - * @param [in] blockDimX - * @param [in] blockDimY - * @param [in] blockDimZ - * @param [in] sharedMemBytes - * @param [in] stream + * @param [in[ f Kernel to launch. + * @param [in] gridDimX X grid dimension specified as multiple of blockDimX. + * @param [in] gridDimY Y grid dimension specified as multiple of blockDimY. + * @param [in] gridDimZ Z grid dimension specified as multiple of blockDimZ. + * @param [in] blockDimX X block dimensions specified in work-items + * @param [in] blockDimY Y grid dimension specified in work-items + * @param [in] blockDimZ Z grid dimension specified in work-items + * @param [in] sharedMemBytes Amount of dynamic shared memory to allocate for this kernel. The kernel can access this with HIP_DYNAMIC_SHARED. + * @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules. * @param [in] kernelParams - * @param [in] extraa + * @param [in] extra Pointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. * - * The function takes the above arguments and run the kernel in hipFunction_t f. with launch parameters specified in gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY and blockDimmZ. The amount of shared memory is specificed and can be used with HIP_DYNAMIC_SHARED. The arguemt extra is used to pass in the arguments for the kernel. * @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue * * @warning kernellParams argument is not yet implemented in HIP. Please use extra instead. Please refer to hip_porting_driver_api.md for sample usage. @@ -1905,17 +2080,86 @@ hipError_t hipIpcCloseMemHandle(void *devPtr); #endif #ifdef __cplusplus -/** - * @brief Returns a PCI Bus Id string for the device. - * @param [out] pciBusId - * @param [in] len - * @param [hipDevice_t] device +/* + * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. * - * @returns #hipSuccess, #hipErrorInavlidDevice + * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level + * hipBindTexture() function. Any memory previously bound to tex is unbound. + * + * @param[in] offset - Offset in bytes + * @param[out] tex - texture to bind + * @param[in] devPtr - Memory area on device + * @param[in] desc - Channel format + * @param[in] size - Size of the memory area pointed to by devPtr + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown + **/ +template +hipError_t hipBindTexture(size_t *offset, + struct texture &tex, + const void *devPtr, + const struct hipChannelFormatDesc *desc, + size_t size=UINT_MAX) +{ + tex._dataPtr = static_cast(devPtr); + + return hipSuccess; +} + +/* + * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. + * + * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level + * hipBindTexture() function. Any memory previously bound to tex is unbound. + * + * @param[in] offset - Offset in bytes + * @param[in] tex - texture to bind + * @param[in] devPtr - Memory area on device + * @param[in] size - Size of the memory area pointed to by devPtr + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown + **/ +template +hipError_t hipBindTexture(size_t *offset, + struct texture &tex, + const void *devPtr, + size_t size=UINT_MAX) +{ + return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size); +} + +template +hipError_t hipBindTextureToArray(struct texture &tex, hipArray* array) { + tex.width = array->width; + tex.height = array->height; + tex._dataPtr = static_cast(array->data); + return hipSuccess; +} + +/* + * @brief Unbinds the textuer bound to @p tex + * + * @param[in] tex - texture to unbind + * + * @return #hipSuccess + **/ +template +hipError_t hipUnbindTexture(struct texture &tex) +{ + tex._dataPtr = NULL; + + return hipSuccess; +} + + + +// doxygen end Texture +/** + * @} */ -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); + + #endif + /** *------------------------------------------------------------------------------------------------- *------------------------------------------------------------------------------------------------- diff --git a/projects/hip/include/hip/hcc_detail/hip_texture.h b/projects/hip/include/hip/hcc_detail/hip_texture.h index fe13f11e49..c6f5a1cfb2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_texture.h +++ b/projects/hip/include/hip/hcc_detail/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,8 @@ THE SOFTWARE. //#pragma once -#ifndef HIP_HCC_DETAIL_TEXTURE_H -#define HIP_HCC_DETAIL_TEXTURE_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H /** * @file hcc_detail/hip_texture.h @@ -31,48 +31,17 @@ THE SOFTWARE. */ #include - +#include +#include +#include //#include //---- //Texture - TODO - likely need to move this to a separate file only included with kernel compilation. #define hipTextureType1D 1 -typedef enum { - hipChannelFormatKindSigned = 0, - hipChannelFormatKindUnsigned, - hipChannelFormatKindFloat, - hipChannelFormatKindNone - -} hipChannelFormatKind; - -typedef struct hipChannelFormatDesc { - int x; - int y; - int z; - int w; - hipChannelFormatKind f; -} hipChannelFormatDesc; - -typedef enum hipTextureReadMode -{ - hipReadModeElementType, ///< Read texture as specified element type -//! @warning cudaReadModeNormalizedFloat is not supported. -} hipTextureReadMode; - -typedef enum hipTextureFilterMode -{ - hipFilterModePoint, ///< Point filter mode. -//! @warning cudaFilterModeLinear is not supported. -} hipTextureFilterMode; - -struct textureReference { - hipTextureFilterMode filterMode; - bool normalized; - hipChannelFormatDesc channelDesc; -}; #if __cplusplus -template +template struct texture : public textureReference { const T * _dataPtr; // pointer to underlying data. @@ -84,95 +53,12 @@ struct texture : public textureReference { }; #endif -typedef struct { - unsigned int width; - unsigned int height; - hipChannelFormatKind f; - void* data; //FIXME: generalize this -} hipArray; - #define tex1Dfetch(_tex, _addr) (_tex._dataPtr[_addr]) #define tex2D(_tex, _dx, _dy) \ _tex._dataPtr[(unsigned int)_dx + (unsigned int)_dy*(_tex.width)] -/** - * @brief Allocate an array on the device. - * - * @param[out] array Pointer to allocated array in device memory - * @param[in] desc Requested channel format - * @param[in] width Requested array allocation width - * @param[in] height Requested array allocation height - * @param[in] flags Requested properties of allocated array - * @return #hipSuccess, #hipErrorMemoryAllocation - * - * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree - */ -hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, - size_t width, size_t height = 0, unsigned int flags = 0); - -/** - * @brief Frees an array on the device. - * - * @param[in] array Pointer to array to free - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError - * - * @see hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree - */ -hipError_t hipFreeArray(hipArray* array); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, - size_t spitch, size_t width, size_t height, hipMemcpyKind kind); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, - const void* src, size_t count, hipMemcpyKind kind); - - /** * @addtogroup API HIP API * @{ @@ -212,120 +98,6 @@ hipChannelFormatDesc hipBindTexture(size_t *offset, struct textureReference *te } #endif -/** - * @brief Returns a channel descriptor using the specified format. - * - * @param[in] x X component - * @param[in] y Y component - * @param[in] z Z component - * @param[in] w W component - * @param[in] f Channel format - * @return Channel descriptor with format f - * - */ -hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); - -// descriptors -template inline hipChannelFormatDesc hipCreateChannelDesc() { - return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(int) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(unsigned int) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(long) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(unsigned long) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(float) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); -} - -/* - * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. - * - * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level - * hipBindTexture() function. Any memory previously bound to tex is unbound. - * - * @param[in] offset - Offset in bytes - * @param[out] tex - texture to bind - * @param[in] devPtr - Memory area on device - * @param[in] desc - Channel format - * @param[in] size - Size of the memory area pointed to by devPtr - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown - **/ -template -hipError_t hipBindTexture(size_t *offset, - struct texture &tex, - const void *devPtr, - const struct hipChannelFormatDesc *desc, - size_t size=UINT_MAX) -{ - tex._dataPtr = static_cast(devPtr); - - return hipSuccess; -} - -/* - * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. - * - * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level - * hipBindTexture() function. Any memory previously bound to tex is unbound. - * - * @param[in] offset - Offset in bytes - * @param[in] tex - texture to bind - * @param[in] devPtr - Memory area on device - * @param[in] size - Size of the memory area pointed to by devPtr - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown - **/ -template -hipError_t hipBindTexture(size_t *offset, - struct texture &tex, - const void *devPtr, - size_t size=UINT_MAX) -{ - return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size); -} - -template -hipError_t hipBindTextureToArray(struct texture &tex, hipArray* array) { - tex.width = array->width; - tex.height = array->height; - tex._dataPtr = static_cast(array->data); - return hipSuccess; -} - -/* - * @brief Unbinds the textuer bound to @p tex - * - * @param[in] tex - texture to unbind - * - * @return #hipSuccess - **/ -template -hipError_t hipUnbindTexture(struct texture &tex) -{ - tex._dataPtr = NULL; - - return hipSuccess; -} - - - -// doxygen end Texture -/** - * @} - */ - // End doxygen API: /** @@ -333,4 +105,3 @@ hipError_t hipUnbindTexture(struct texture &tex) */ #endif - diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index ffe15a27a4..35c6c23548 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,412 +25,4094 @@ THE SOFTWARE. * @brief Defines the different newt vector types for HIP runtime. */ -#ifndef HIP_VECTOR_TYPES_H -#define HIP_VECTOR_TYPES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H #if defined (__HCC__) && (__hcc_workweek__ < 16032) #error("This version of HIP requires a newer version of HCC."); #endif -#if 0 -#include +#include "hip/hcc_detail/host_defines.h" -using namespace hc::short_vector; +#define MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x) { } \ +__device__ __host__ type(const type& val) : x(val.x) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y), z(val.z) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y), z(val.z) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y), z(val.z), w(val.w) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y), z(val.z), w(val.w) { } -//-- Signed -// Define char vector types -typedef hc::short_vector::char1 char1; -typedef hc::short_vector::char2 char2; -typedef hc::short_vector::char3 char3; -typedef hc::short_vector::char4 char4; +#define MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val) {} \ -// Define short vector types -typedef hc::short_vector::short1 short1; -typedef hc::short_vector::short2 short2; -typedef hc::short_vector::short3 short3; -typedef hc::short_vector::short4 short4; +#define MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val) {} \ +__device__ __host__ type(type1 val1, type1 val2) : x(val1), y(val2) {} -// Define int vector types -typedef hc::short_vector::int1 int1; -typedef hc::short_vector::int2 int2; -typedef hc::short_vector::int3 int3; -typedef hc::short_vector::int4 int4; +#define MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val), z(val) {} \ +__device__ __host__ type(type1 val1, type1 val2, type1 val3) : x(val1), y(val2), z(val3) {} -// Define long vector types -typedef hc::short_vector::long1 long1; -typedef hc::short_vector::long2 long2; -typedef hc::short_vector::long3 long3; -typedef hc::short_vector::long4 long4; +#define MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val), z(val), w(val) {} \ +__device__ __host__ type(type1 val1, type1 val2, type1 val3, type1 val4) : x(val1), y(val2), z(val3), w(val4) {} -// Define longlong vector types -typedef hc::short_vector::longlong1 longlong1; -typedef hc::short_vector::longlong2 longlong2; -typedef hc::short_vector::longlong3 longlong3; -typedef hc::short_vector::longlong4 longlong4; +struct uchar1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(uchar1) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed long long) + #endif + unsigned char x; -//-- Unsigned -// Define uchar vector types -typedef hc::short_vector::uchar1 uchar1; -typedef hc::short_vector::uchar2 uchar2; -typedef hc::short_vector::uchar3 uchar3; -typedef hc::short_vector::uchar4 uchar4; +} __attribute__((aligned(1))); -// Define ushort vector types -typedef hc::short_vector::ushort1 ushort1; -typedef hc::short_vector::ushort2 ushort2; -typedef hc::short_vector::ushort3 ushort3; -typedef hc::short_vector::ushort4 ushort4; +struct uchar2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(uchar2) -// Define uint vector types -typedef hc::short_vector::uint1 uint1; -typedef hc::short_vector::uint2 uint2; -typedef hc::short_vector::uint3 uint3; -typedef hc::short_vector::uint4 uint4; - -// Define ulong vector types -typedef hc::short_vector::ulong1 ulong1; -typedef hc::short_vector::ulong2 ulong2; -typedef hc::short_vector::ulong3 ulong3; -typedef hc::short_vector::ulong4 ulong4; - -// Define ulonglong vector types -typedef hc::short_vector::ulonglong1 ulonglong1; -typedef hc::short_vector::ulonglong2 ulonglong2; -typedef hc::short_vector::ulonglong3 ulonglong3; -typedef hc::short_vector::ulonglong4 ulonglong4; - - -//-- Floating point -// Define float vector types -typedef hc::short_vector::float1 float1; -typedef hc::short_vector::float2 float2; -typedef hc::short_vector::float3 float3; -typedef hc::short_vector::float4 float4; - -// Define double vector types -typedef hc::short_vector::double1 double1; -typedef hc::short_vector::double2 double2; -typedef hc::short_vector::double3 double3; -typedef hc::short_vector::double4 double4; - -#else - -#define __hip_align(name, val, data) \ - __attribute__((aligned(val))) name \ - { data } - -struct __hip_align(char1, 1, signed char x;); -struct __hip_align(uchar1, 1, unsigned char x;); - -struct __hip_align(char2, 2, signed char x; signed char y;); -struct __hip_align(uchar2, 2, unsigned char x; unsigned char y;); - -struct char3 -{ - signed char x, y, z; -}; - -struct uchar3 -{ - unsigned char x, y, z; -}; - -struct char4 -{ - union { - signed char x, y, z, w; - unsigned int val; + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed long long) + #endif + union { + struct { + unsigned char x, y; }; + unsigned short a; + }; +} __attribute__((aligned(2))); + +struct uchar3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(uchar3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed long long) + #endif + unsigned char x, y, z; }; -struct uchar4 -{ - union { - unsigned char x, y, z, w; - unsigned int val; +struct uchar4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(uchar4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed long long) + #endif + union { + struct { + unsigned char x, y, z, w; }; + unsigned int a; + }; +} __attribute__((aligned(4))); + + +struct char1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(char1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed long long) + #endif + signed char x; +} __attribute__((aligned(1))); + +struct char2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(char2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed long long) + #endif + union { + struct { + signed char x, y; + }; + unsigned short a; + }; +} __attribute__((aligned(2))); + +struct char3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(char3) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed long long) + #endif + signed char x, y, z; }; -//struct __hip_align(char4, 4, signed char x; signed char y; signed char z; signed char w;); -//struct __hip_align(uchar4, 4, unsigned char x; unsigned char y; unsigned char z; unsigned char w;); +struct char4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(char4) -struct __hip_align(short1, 2, signed short x;); -struct __hip_align(ushort1, 2, unsigned short x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed long long) + #endif + union { + struct { + signed char x, y, z, w; + }; + unsigned int a; + }; +} __attribute__((aligned(4))); -struct __hip_align(short2, 4, signed short x; signed short y;); -struct __hip_align(ushort2, 4, unsigned short x; unsigned short y;); -struct short3 -{ - signed short x, y, z; + +struct ushort1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ushort1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed long long) + #endif + unsigned short x; +} __attribute__((aligned(2))); + +struct ushort2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ushort2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed long long) + #endif + union { + struct { + unsigned short x, y; + }; + unsigned int a; + }; +} __attribute__((aligned(4))); + +struct ushort3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ushort3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed long long) + #endif + unsigned short x, y, z; }; -struct ushort3 -{ - unsigned short x, y, z; +struct ushort4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ushort4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed long long) + #endif + union { + struct { + unsigned short x, y, z, w; + }; + unsigned int a, b; + }; +} __attribute__((aligned(8))); + +struct short1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(short1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed long long) + #endif + signed short x; +} __attribute__((aligned(2))); + +struct short2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(short2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed long long) + #endif + union { + struct { + signed short x, y; + }; + unsigned int a; + }; + +} __attribute__((aligned(4))); + +struct short3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(short3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed long long) + #endif + signed short x, y, z; }; -struct __hip_align(short4, 8, signed short x; signed short y; signed short z; signed short w;); -struct __hip_align(ushort4, 8, unsigned short x; unsigned short y; unsigned short z; unsigned short w;); +struct short4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(short4) -struct __hip_align(int1, 4, signed int x;); -struct __hip_align(uint1, 4, unsigned int x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed long long) + #endif + union { + struct { + signed short x, y, z, w; + }; + unsigned int a, b; + }; +} __attribute__((aligned(8))); -struct __hip_align(int2, 8, signed int x; signed int y;); -struct __hip_align(uint2, 8, unsigned int x; unsigned int y;); -struct int3{ - signed int x, y, z; -}; -struct uint3{ - unsigned int x, y, z; +struct uint1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(uint1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed long long) + #endif + unsigned int x; +} __attribute__((aligned(4))); + +struct uint2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(uint2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed long long) + #endif + unsigned int x, y; +} __attribute__((aligned(8))); + +struct uint3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(uint3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed long long) + #endif + unsigned int x, y, z; }; -struct __hip_align(int4, 16, signed int x; signed int y; signed int z; signed int w;); -struct __hip_align(uint4, 16, unsigned int x; unsigned int y; unsigned int z; unsigned int w;); +struct uint4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(uint4) -struct __hip_align(long1, 8, long int x;); -struct __hip_align(ulong1, 8, unsigned long x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed long long) + #endif + unsigned int x, y, z, w; +} __attribute__((aligned(16))); -struct __hip_align(long2, 16, long int x; long int y;); -struct __hip_align(ulong2, 16, unsigned long x; unsigned long y;); +struct int1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(int1) -struct long3{ - long int x, y, z; -}; -struct ulong3{ - unsigned long x, y, z; + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed long long) + #endif + signed int x; +} __attribute__((aligned(4))); + +struct int2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(int2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed long long) + #endif + signed int x, y; +} __attribute__((aligned(8))); + +struct int3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(int3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed long long) + #endif + signed int x, y, z; }; -struct __hip_align(long4, 32, long int x; long int y; long int z; long int w;); -struct __hip_align(ulong4, 32, unsigned long x; unsigned long y; unsigned long z; unsigned long w;); +struct int4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(int4) -struct float1 -{ - float x; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed long long) + #endif + signed int x, y, z, w; +} __attribute__((aligned(16))); + + +struct float1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(float1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed long long) + #endif + float x; +} __attribute__((aligned(4))); + +struct float2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(float2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed long long) + #endif + float x, y; +} __attribute__((aligned(8))); + +struct float3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(float3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed long long) + #endif + float x, y, z; }; -struct __hip_align(float2, 8, float x; float y;); +struct float4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(float4) -struct float3 -{ - float x, y, z; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed long long) + #endif + float x, y, z, w; +} __attribute__((aligned(16))); + + + +struct double1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(double1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed long long) + #endif + double x; +} __attribute__((aligned(8))); + +struct double2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(double2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed long long) + #endif + double x, y; +} __attribute__((aligned(16))); + +struct double3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(double3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed long long) + #endif + double x, y, z; }; -struct __hip_align(float4, 16, float x; float y; float z; float w;); +struct double4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(double4) -struct __hip_align(longlong1, 16, long long int x;); -struct __hip_align(ulonglong1, 16, unsigned long long int x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed long long) + #endif + double x, y, z, w; +} __attribute__((aligned(32))); -struct __attribute__((aligned(32))) longlong2 -{ - long long int x, y; + +struct ulong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ulong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed long long) + #endif + unsigned long x; +} __attribute__((aligned(8))); + +struct ulong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ulong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed long long) + #endif + unsigned long x, y; +} __attribute__((aligned(16))); + +struct ulong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ulong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed long long) + #endif + unsigned long x, y, z; }; -struct __attribute__((aligned(32))) ulonglong2 -{ - unsigned long long int x, y; +struct ulong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ulong4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed long long) + #endif + unsigned long x, y, z, w; +} __attribute__((aligned(32))); + + +struct long1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(long1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed long long) + #endif + signed long x; +} __attribute__((aligned(8))); + +struct long2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(long2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed long long) + #endif + signed long x, y; +} __attribute__((aligned(16))); + +struct long3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(long3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed long long) + #endif + signed long x, y, z; }; -struct longlong3 -{ - long long int x, y, z; +struct long4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(long4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed long long) + #endif + signed long x, y, z, w; +} __attribute__((aligned(32))); + + +struct ulonglong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed long long) + #endif + unsigned long long x; +} __attribute__((aligned(8))); + +struct ulonglong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed long long) + #endif + unsigned long long x, y; +} __attribute__((aligned(16))); + +struct ulonglong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed long long) + #endif + unsigned long long x, y, z; }; -struct ulonglong3 -{ - unsigned long long int x, y, z; +struct ulonglong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed long long) + #endif + unsigned long long x, y, z, w; +} __attribute__((aligned(32))); + + +struct longlong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(longlong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed long long) + #endif + signed long long x; +} __attribute__((aligned(8))); + +struct longlong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(longlong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed long long) + #endif + signed long long x, y; +} __attribute__((aligned(16))); + +struct longlong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(longlong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed long long) + #endif + signed long long x, y, z; }; -struct __attribute__((aligned(64))) longlong4 -{ - long long int x, y, z, w; -}; +struct longlong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(longlong4) -struct __attribute__((aligned(64))) ulonglong4 -{ - unsigned long long int x, y, z, w; -}; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed long long) + #endif + signed long x, y, z, w; +} __attribute__((aligned(32))); -struct double1 -{ - double x; -}; +#define DECLOP_MAKE_ONE_COMPONENT(comp, type) \ +__device__ __host__ static inline struct type make_##type(comp x) { \ + struct type ret; \ + ret.x = x; \ + return ret; \ +} -struct __attribute__((aligned(16))) double2 -{ - double x, y; -}; +#define DECLOP_MAKE_TWO_COMPONENT(comp, type) \ +__device__ __host__ static inline struct type make_##type(comp x, comp y) { \ + struct type ret; \ + ret.x = x; \ + ret.y = y; \ + return ret; \ +} -struct double3 -{ - double x, y, z; -}; +#define DECLOP_MAKE_THREE_COMPONENT(comp, type) \ +__device__ __host__ static inline struct type make_##type(comp x, comp y, comp z) { \ + struct type ret; \ + ret.x = x; \ + ret.y = y; \ + ret.z = z; \ + return ret; \ +} -struct __attribute__((aligned(32))) double4 -{ - double x, y, z, w; -}; +#define DECLOP_MAKE_FOUR_COMPONENT(comp, type) \ +__device__ __host__ static inline struct type make_##type(comp x, comp y, comp z, comp w) { \ + struct type ret; \ + ret.x = x; \ + ret.y = y; \ + ret.z = z; \ + ret.w = w; \ + return ret; \ +} -#endif +DECLOP_MAKE_ONE_COMPONENT(unsigned char, uchar1); +DECLOP_MAKE_TWO_COMPONENT(unsigned char, uchar2); +DECLOP_MAKE_THREE_COMPONENT(unsigned char, uchar3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned char, uchar4); -#if __HCC__ -#include"hip/hcc_detail/host_defines.h" -#define __HIP_DEVICE__ __device__ __host__ -#else -#define __HIP_DEVICE__ -#endif +DECLOP_MAKE_ONE_COMPONENT(signed char, char1); +DECLOP_MAKE_TWO_COMPONENT(signed char, char2); +DECLOP_MAKE_THREE_COMPONENT(signed char, char3); +DECLOP_MAKE_FOUR_COMPONENT(signed char, char4); -__HIP_DEVICE__ char1 make_char1(signed char ); -__HIP_DEVICE__ char2 make_char2(signed char, signed char ); -__HIP_DEVICE__ char3 make_char3(signed char, signed char, signed char ); -__HIP_DEVICE__ char4 make_char4(signed char, signed char, signed char, signed char ); +DECLOP_MAKE_ONE_COMPONENT(unsigned short, ushort1); +DECLOP_MAKE_TWO_COMPONENT(unsigned short, ushort2); +DECLOP_MAKE_THREE_COMPONENT(unsigned short, ushort3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned short, ushort4); -__HIP_DEVICE__ short1 make_short1(short ); -__HIP_DEVICE__ short2 make_short2(short, short ); -__HIP_DEVICE__ short3 make_short3(short, short, short ); -__HIP_DEVICE__ short4 make_short4(short, short, short, short ); +DECLOP_MAKE_ONE_COMPONENT(signed short, short1); +DECLOP_MAKE_TWO_COMPONENT(signed short, short2); +DECLOP_MAKE_THREE_COMPONENT(signed short, short3); +DECLOP_MAKE_FOUR_COMPONENT(signed short, short4); -__HIP_DEVICE__ int1 make_int1(int ); -__HIP_DEVICE__ int2 make_int2(int, int ); -__HIP_DEVICE__ int3 make_int3(int, int, int ); -__HIP_DEVICE__ int4 make_int4(int, int, int, int ); +DECLOP_MAKE_ONE_COMPONENT(unsigned int, uint1); +DECLOP_MAKE_TWO_COMPONENT(unsigned int, uint2); +DECLOP_MAKE_THREE_COMPONENT(unsigned int, uint3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned int, uint4); -__HIP_DEVICE__ long1 make_long1(long ); -__HIP_DEVICE__ long2 make_long2(long, long ); -__HIP_DEVICE__ long3 make_long3(long, long, long ); -__HIP_DEVICE__ long4 make_long4(long, long, long, long ); +DECLOP_MAKE_ONE_COMPONENT(signed int, int1); +DECLOP_MAKE_TWO_COMPONENT(signed int, int2); +DECLOP_MAKE_THREE_COMPONENT(signed int, int3); +DECLOP_MAKE_FOUR_COMPONENT(signed int, int4); -__HIP_DEVICE__ longlong1 make_longlong1(long long ); -__HIP_DEVICE__ longlong2 make_longlong2(long long, long long ); -__HIP_DEVICE__ longlong3 make_longlong3(long long, long long, long long ); -__HIP_DEVICE__ longlong4 make_longlong4(long long, long long, long long, long long ); +DECLOP_MAKE_ONE_COMPONENT(float, float1); +DECLOP_MAKE_TWO_COMPONENT(float, float2); +DECLOP_MAKE_THREE_COMPONENT(float, float3); +DECLOP_MAKE_FOUR_COMPONENT(float, float4); -__HIP_DEVICE__ uchar1 make_uchar1(unsigned char ); -__HIP_DEVICE__ uchar2 make_uchar2(unsigned char, unsigned char ); -__HIP_DEVICE__ uchar3 make_uchar3(unsigned char, unsigned char, unsigned char ); -__HIP_DEVICE__ uchar4 make_uchar4(unsigned char, unsigned char, unsigned char, unsigned char ); +DECLOP_MAKE_ONE_COMPONENT(double, double1); +DECLOP_MAKE_TWO_COMPONENT(double, double2); +DECLOP_MAKE_THREE_COMPONENT(double, double3); +DECLOP_MAKE_FOUR_COMPONENT(double, double4); -__HIP_DEVICE__ ushort1 make_ushort1(unsigned short ); -__HIP_DEVICE__ ushort2 make_ushort2(unsigned short, unsigned short ); -__HIP_DEVICE__ ushort3 make_ushort3(unsigned short, unsigned short, unsigned short ); -__HIP_DEVICE__ ushort4 make_ushort4(unsigned short, unsigned short, unsigned short, unsigned short ); +DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulong1); +DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulong2); +DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulong3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulong4); -__HIP_DEVICE__ uint1 make_uint1(unsigned int ); -__HIP_DEVICE__ uint2 make_uint2(unsigned int, unsigned int ); -__HIP_DEVICE__ uint3 make_uint3(unsigned int, unsigned int, unsigned int ); -__HIP_DEVICE__ uint4 make_uint4(unsigned int, unsigned int, unsigned int, unsigned int ); +DECLOP_MAKE_ONE_COMPONENT(signed long, long1); +DECLOP_MAKE_TWO_COMPONENT(signed long, long2); +DECLOP_MAKE_THREE_COMPONENT(signed long, long3); +DECLOP_MAKE_FOUR_COMPONENT(signed long, long4); -__HIP_DEVICE__ ulong1 make_ulong1(unsigned long ); -__HIP_DEVICE__ ulong2 make_ulong2(unsigned long, unsigned long ); -__HIP_DEVICE__ ulong3 make_ulong3(unsigned long, unsigned long, unsigned long ); -__HIP_DEVICE__ ulong4 make_ulong4(unsigned long, unsigned long, unsigned long, unsigned long ); +DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulonglong1); +DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulonglong2); +DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulonglong3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulonglong4); -__HIP_DEVICE__ ulonglong1 make_ulonglong1(unsigned long long ); -__HIP_DEVICE__ ulonglong2 make_ulonglong2(unsigned long long, unsigned long long); -__HIP_DEVICE__ ulonglong3 make_ulonglong3(unsigned long long, unsigned long long, unsigned long long); -__HIP_DEVICE__ ulonglong4 make_ulonglong4(unsigned long long, unsigned long long, unsigned long long, unsigned long long ); +DECLOP_MAKE_ONE_COMPONENT(signed long, longlong1); +DECLOP_MAKE_TWO_COMPONENT(signed long, longlong2); +DECLOP_MAKE_THREE_COMPONENT(signed long, longlong3); +DECLOP_MAKE_FOUR_COMPONENT(signed long, longlong4); -__HIP_DEVICE__ float1 make_float1(float ); -__HIP_DEVICE__ float2 make_float2(float, float ); -__HIP_DEVICE__ float3 make_float3(float, float, float ); -__HIP_DEVICE__ float4 make_float4(float, float, float, float ); -__HIP_DEVICE__ double1 make_double1(double ); -__HIP_DEVICE__ double2 make_double2(double, double ); -__HIP_DEVICE__ double3 make_double3(double, double, double ); -__HIP_DEVICE__ double4 make_double4(double, double, double, double ); +#if __cplusplus -extern __HIP_DEVICE__ double __longlong_as_double(long long int x); -extern __HIP_DEVICE__ long long int __double_as_longlong(double x); +#define DECLOP_1VAR_2IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_ASSIGN(type, op) \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + return lhs; \ +} + +#define DECLOP_1VAR_PREOP(type, op) \ +__device__ __host__ static inline type& operator op (type& val) { \ + op val.x; \ + return val; \ +} + +#define DECLOP_1VAR_POSTOP(type, op) \ +__device__ __host__ static inline type operator op (type& val, int) { \ + type ret; \ + ret.x = val.x; \ + val.x op; \ + return ret; \ +} + +#define DECLOP_1VAR_COMP(type, op) \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ + return lhs.x op rhs.x; \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return lhs.x op rhs.x; \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return lhs.x op rhs.x ; \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return lhs.x op rhs.x ; \ +} + +#define DECLOP_1VAR_1IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op(type& rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ static inline bool operator op (type& rhs) { \ + return op rhs.x; \ +} + +/* + Two Element Access +*/ + +#define DECLOP_2VAR_2IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_ASSIGN(type, op) \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + return lhs; \ +} + +#define DECLOP_2VAR_PREOP(type, op) \ +__device__ __host__ static inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + return val; \ +} + +#define DECLOP_2VAR_POSTOP(type, op) \ +__device__ __host__ static inline type operator op (type& val, int) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + val.x op; \ + val.y op; \ + return ret; \ +} + +#define DECLOP_2VAR_COMP(type, op) \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} + +#define DECLOP_2VAR_1IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ static inline bool operator op (type &rhs) { \ + return (op rhs.x) && (op rhs.y); \ +} /* -///--- -// Inline functions for creating vector types from basic types -#define ONE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x) { VT t; t.x = x; return t; }; -#define TWO_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y) { VT t; t.x=x; t.y=y; return t; }; -#define THREE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y, T z) { VT t; t.x=x; t.y=y; t.z=z; return t; }; -#define FOUR_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y, T z, T w) { VT t; t.x=x; t.y=y; t.z=z; t.w=w; return t; }; - - -//signed: -ONE_COMPONENT_ACCESS (signed char, char1); -TWO_COMPONENT_ACCESS (signed char, char2); -THREE_COMPONENT_ACCESS(signed char, char3); -FOUR_COMPONENT_ACCESS (signed char, char4); - -ONE_COMPONENT_ACCESS (short, short1); -TWO_COMPONENT_ACCESS (short, short2); -THREE_COMPONENT_ACCESS(short, short3); -FOUR_COMPONENT_ACCESS (short, short4); - -ONE_COMPONENT_ACCESS (int, int1); -TWO_COMPONENT_ACCESS (int, int2); -THREE_COMPONENT_ACCESS(int, int3); -FOUR_COMPONENT_ACCESS (int, int4); - -ONE_COMPONENT_ACCESS (long int, long1); -TWO_COMPONENT_ACCESS (long int, long2); -THREE_COMPONENT_ACCESS(long int, long3); -FOUR_COMPONENT_ACCESS (long int, long4); - -ONE_COMPONENT_ACCESS (long long int, ulong1); -TWO_COMPONENT_ACCESS (long long int, ulong2); -THREE_COMPONENT_ACCESS(long long int, ulong3); -FOUR_COMPONENT_ACCESS (long long int, ulong4); - -ONE_COMPONENT_ACCESS (long long int, longlong1); -TWO_COMPONENT_ACCESS (long long int, longlong2); -THREE_COMPONENT_ACCESS(long long int, longlong3); -FOUR_COMPONENT_ACCESS (long long int, longlong4); - - -// unsigned: -ONE_COMPONENT_ACCESS (unsigned char, uchar1); -TWO_COMPONENT_ACCESS (unsigned char, uchar2); -THREE_COMPONENT_ACCESS(unsigned char, uchar3); -FOUR_COMPONENT_ACCESS (unsigned char, uchar4); - -ONE_COMPONENT_ACCESS (unsigned short, ushort1); -TWO_COMPONENT_ACCESS (unsigned short, ushort2); -THREE_COMPONENT_ACCESS(unsigned short, ushort3); -FOUR_COMPONENT_ACCESS (unsigned short, ushort4); - -ONE_COMPONENT_ACCESS (unsigned int, uint1); -TWO_COMPONENT_ACCESS (unsigned int, uint2); -THREE_COMPONENT_ACCESS(unsigned int, uint3); -FOUR_COMPONENT_ACCESS (unsigned int, uint4); - -ONE_COMPONENT_ACCESS (unsigned long int, ulong1); -TWO_COMPONENT_ACCESS (unsigned long int, ulong2); -THREE_COMPONENT_ACCESS(unsigned long int, ulong3); -FOUR_COMPONENT_ACCESS (unsigned long int, ulong4); - -ONE_COMPONENT_ACCESS (unsigned long long int, ulong1); -TWO_COMPONENT_ACCESS (unsigned long long int, ulong2); -THREE_COMPONENT_ACCESS(unsigned long long int, ulong3); -FOUR_COMPONENT_ACCESS (unsigned long long int, ulong4); - -ONE_COMPONENT_ACCESS (unsigned long long int, ulonglong1); -TWO_COMPONENT_ACCESS (unsigned long long int, ulonglong2); -THREE_COMPONENT_ACCESS(unsigned long long int, ulonglong3); -FOUR_COMPONENT_ACCESS (unsigned long long int, ulonglong4); - - -//Floating point -ONE_COMPONENT_ACCESS (float, float1); -TWO_COMPONENT_ACCESS (float, float2); -THREE_COMPONENT_ACCESS(float, float3); -FOUR_COMPONENT_ACCESS (float, float4); - -ONE_COMPONENT_ACCESS (double, double1); -TWO_COMPONENT_ACCESS (double, double2); -THREE_COMPONENT_ACCESS(double, double3); -FOUR_COMPONENT_ACCESS (double, double4); + Three Element Access */ +#define DECLOP_3VAR_2IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + ret.z = lhs.z op rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + ret.z = lhs.z * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + ret.z = lhs * rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_ASSIGN(type, op) \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + lhs.z op rhs.z; \ + return lhs; \ +} + +#define DECLOP_3VAR_PREOP(type, op) \ +__device__ __host__ static inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + op val.z; \ + return val; \ +} + +#define DECLOP_3VAR_POSTOP(type, op) \ +__device__ __host__ static inline type operator op (type& val, int) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + ret.z = val.z; \ + val.x op; \ + val.y op; \ + val.z op; \ + return ret; \ +} + +#define DECLOP_3VAR_COMP(type, op) \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ + +#define DECLOP_3VAR_1IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + ret.z = op rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ static inline bool operator op (type &rhs) { \ + return (op rhs.x) && (op rhs.y) && (op rhs.z); \ +} + + +/* + Four Element Access +*/ + +#define DECLOP_4VAR_2IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op ( const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + ret.z = lhs.z op rhs.z; \ + ret.w = lhs.w op rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + ret.z = lhs.z * rhs; \ + ret.w = lhs.w * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + ret.z = lhs * rhs.z; \ + ret.w = lhs * rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_ASSIGN(type, op) \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + lhs.z op rhs.z; \ + lhs.w op rhs.w; \ + return lhs; \ +} + +#define DECLOP_4VAR_PREOP(type, op) \ +__device__ __host__ static inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + op val.z; \ + op val.w; \ + return val; \ +} + +#define DECLOP_4VAR_POSTOP(type, op) \ +__device__ __host__ static inline type operator op (type& val, int) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + ret.z = val.z; \ + ret.w = val.w; \ + val.x op; \ + val.y op; \ + val.z op; \ + val.w op; \ + return ret; \ +} + +#define DECLOP_4VAR_COMP(type, op) \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} + +#define DECLOP_4VAR_1IN_1OUT(type, op) \ +__device__ __host__ static inline type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + ret.z = op rhs.z; \ + ret.w = op rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ static inline bool operator op (type &rhs) { \ + return (op rhs.x) && (op rhs.y) && (op rhs.z) && (op rhs.w); \ +} + + +/* +Overloading operators +*/ + +// UNSIGNED CHAR1 + +DECLOP_1VAR_2IN_1OUT(uchar1, +) +DECLOP_1VAR_2IN_1OUT(uchar1, -) +DECLOP_1VAR_2IN_1OUT(uchar1, *) +DECLOP_1VAR_2IN_1OUT(uchar1, /) +DECLOP_1VAR_2IN_1OUT(uchar1, %) +DECLOP_1VAR_2IN_1OUT(uchar1, &) +DECLOP_1VAR_2IN_1OUT(uchar1, |) +DECLOP_1VAR_2IN_1OUT(uchar1, ^) +DECLOP_1VAR_2IN_1OUT(uchar1, <<) +DECLOP_1VAR_2IN_1OUT(uchar1, >>) + + +DECLOP_1VAR_ASSIGN(uchar1, +=) +DECLOP_1VAR_ASSIGN(uchar1, -=) +DECLOP_1VAR_ASSIGN(uchar1, *=) +DECLOP_1VAR_ASSIGN(uchar1, /=) +DECLOP_1VAR_ASSIGN(uchar1, %=) +DECLOP_1VAR_ASSIGN(uchar1, &=) +DECLOP_1VAR_ASSIGN(uchar1, |=) +DECLOP_1VAR_ASSIGN(uchar1, ^=) +DECLOP_1VAR_ASSIGN(uchar1, <<=) +DECLOP_1VAR_ASSIGN(uchar1, >>=) + +DECLOP_1VAR_PREOP(uchar1, ++) +DECLOP_1VAR_PREOP(uchar1, --) + +DECLOP_1VAR_POSTOP(uchar1, ++) +DECLOP_1VAR_POSTOP(uchar1, --) + +DECLOP_1VAR_COMP(uchar1, ==) +DECLOP_1VAR_COMP(uchar1, !=) +DECLOP_1VAR_COMP(uchar1, <) +DECLOP_1VAR_COMP(uchar1, >) +DECLOP_1VAR_COMP(uchar1, <=) +DECLOP_1VAR_COMP(uchar1, >=) + +DECLOP_1VAR_COMP(uchar1, &&) +DECLOP_1VAR_COMP(uchar1, ||) + +DECLOP_1VAR_1IN_1OUT(uchar1, ~) +DECLOP_1VAR_1IN_BOOLOUT(uchar1, !) + +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, float) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, double) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed long long) + +// UNSIGNED CHAR2 + +DECLOP_2VAR_2IN_1OUT(uchar2, +) +DECLOP_2VAR_2IN_1OUT(uchar2, -) +DECLOP_2VAR_2IN_1OUT(uchar2, *) +DECLOP_2VAR_2IN_1OUT(uchar2, /) +DECLOP_2VAR_2IN_1OUT(uchar2, %) +DECLOP_2VAR_2IN_1OUT(uchar2, &) +DECLOP_2VAR_2IN_1OUT(uchar2, |) +DECLOP_2VAR_2IN_1OUT(uchar2, ^) +DECLOP_2VAR_2IN_1OUT(uchar2, <<) +DECLOP_2VAR_2IN_1OUT(uchar2, >>) + +DECLOP_2VAR_ASSIGN(uchar2, +=) +DECLOP_2VAR_ASSIGN(uchar2, -=) +DECLOP_2VAR_ASSIGN(uchar2, *=) +DECLOP_2VAR_ASSIGN(uchar2, /=) +DECLOP_2VAR_ASSIGN(uchar2, %=) +DECLOP_2VAR_ASSIGN(uchar2, &=) +DECLOP_2VAR_ASSIGN(uchar2, |=) +DECLOP_2VAR_ASSIGN(uchar2, ^=) +DECLOP_2VAR_ASSIGN(uchar2, <<=) +DECLOP_2VAR_ASSIGN(uchar2, >>=) + +DECLOP_2VAR_PREOP(uchar2, ++) +DECLOP_2VAR_PREOP(uchar2, --) + +DECLOP_2VAR_POSTOP(uchar2, ++) +DECLOP_2VAR_POSTOP(uchar2, --) + +DECLOP_2VAR_COMP(uchar2, ==) +DECLOP_2VAR_COMP(uchar2, !=) +DECLOP_2VAR_COMP(uchar2, <) +DECLOP_2VAR_COMP(uchar2, >) +DECLOP_2VAR_COMP(uchar2, <=) +DECLOP_2VAR_COMP(uchar2, >=) + +DECLOP_2VAR_COMP(uchar2, &&) +DECLOP_2VAR_COMP(uchar2, ||) + +DECLOP_2VAR_1IN_1OUT(uchar2, ~) +DECLOP_2VAR_1IN_BOOLOUT(uchar2, !) + +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, float) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, double) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed long long) + +// UNSIGNED CHAR3 + +DECLOP_3VAR_2IN_1OUT(uchar3, +) +DECLOP_3VAR_2IN_1OUT(uchar3, -) +DECLOP_3VAR_2IN_1OUT(uchar3, *) +DECLOP_3VAR_2IN_1OUT(uchar3, /) +DECLOP_3VAR_2IN_1OUT(uchar3, %) +DECLOP_3VAR_2IN_1OUT(uchar3, &) +DECLOP_3VAR_2IN_1OUT(uchar3, |) +DECLOP_3VAR_2IN_1OUT(uchar3, ^) +DECLOP_3VAR_2IN_1OUT(uchar3, <<) +DECLOP_3VAR_2IN_1OUT(uchar3, >>) + +DECLOP_3VAR_ASSIGN(uchar3, +=) +DECLOP_3VAR_ASSIGN(uchar3, -=) +DECLOP_3VAR_ASSIGN(uchar3, *=) +DECLOP_3VAR_ASSIGN(uchar3, /=) +DECLOP_3VAR_ASSIGN(uchar3, %=) +DECLOP_3VAR_ASSIGN(uchar3, &=) +DECLOP_3VAR_ASSIGN(uchar3, |=) +DECLOP_3VAR_ASSIGN(uchar3, ^=) +DECLOP_3VAR_ASSIGN(uchar3, <<=) +DECLOP_3VAR_ASSIGN(uchar3, >>=) + +DECLOP_3VAR_PREOP(uchar3, ++) +DECLOP_3VAR_PREOP(uchar3, --) + +DECLOP_3VAR_POSTOP(uchar3, ++) +DECLOP_3VAR_POSTOP(uchar3, --) + +DECLOP_3VAR_COMP(uchar3, ==) +DECLOP_3VAR_COMP(uchar3, !=) +DECLOP_3VAR_COMP(uchar3, <) +DECLOP_3VAR_COMP(uchar3, >) +DECLOP_3VAR_COMP(uchar3, <=) +DECLOP_3VAR_COMP(uchar3, >=) + +DECLOP_3VAR_COMP(uchar3, &&) +DECLOP_3VAR_COMP(uchar3, ||) + +DECLOP_3VAR_1IN_1OUT(uchar3, ~) +DECLOP_3VAR_1IN_BOOLOUT(uchar3, !) + +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, float) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, double) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed long long) + +// UNSIGNED CHAR4 + +DECLOP_4VAR_2IN_1OUT(uchar4, +) +DECLOP_4VAR_2IN_1OUT(uchar4, -) +DECLOP_4VAR_2IN_1OUT(uchar4, *) +DECLOP_4VAR_2IN_1OUT(uchar4, /) +DECLOP_4VAR_2IN_1OUT(uchar4, %) +DECLOP_4VAR_2IN_1OUT(uchar4, &) +DECLOP_4VAR_2IN_1OUT(uchar4, |) +DECLOP_4VAR_2IN_1OUT(uchar4, ^) +DECLOP_4VAR_2IN_1OUT(uchar4, <<) +DECLOP_4VAR_2IN_1OUT(uchar4, >>) + +DECLOP_4VAR_ASSIGN(uchar4, +=) +DECLOP_4VAR_ASSIGN(uchar4, -=) +DECLOP_4VAR_ASSIGN(uchar4, *=) +DECLOP_4VAR_ASSIGN(uchar4, /=) +DECLOP_4VAR_ASSIGN(uchar4, %=) +DECLOP_4VAR_ASSIGN(uchar4, &=) +DECLOP_4VAR_ASSIGN(uchar4, |=) +DECLOP_4VAR_ASSIGN(uchar4, ^=) +DECLOP_4VAR_ASSIGN(uchar4, <<=) +DECLOP_4VAR_ASSIGN(uchar4, >>=) + +DECLOP_4VAR_PREOP(uchar4, ++) +DECLOP_4VAR_PREOP(uchar4, --) + +DECLOP_4VAR_POSTOP(uchar4, ++) +DECLOP_4VAR_POSTOP(uchar4, --) + +DECLOP_4VAR_COMP(uchar4, ==) +DECLOP_4VAR_COMP(uchar4, !=) +DECLOP_4VAR_COMP(uchar4, <) +DECLOP_4VAR_COMP(uchar4, >) +DECLOP_4VAR_COMP(uchar4, <=) +DECLOP_4VAR_COMP(uchar4, >=) + +DECLOP_4VAR_COMP(uchar4, &&) +DECLOP_4VAR_COMP(uchar4, ||) + +DECLOP_4VAR_1IN_1OUT(uchar4, ~) +DECLOP_4VAR_1IN_BOOLOUT(uchar4, !) + +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, float) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, double) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed long long) + +// SIGNED CHAR1 + +DECLOP_1VAR_2IN_1OUT(char1, +) +DECLOP_1VAR_2IN_1OUT(char1, -) +DECLOP_1VAR_2IN_1OUT(char1, *) +DECLOP_1VAR_2IN_1OUT(char1, /) +DECLOP_1VAR_2IN_1OUT(char1, %) +DECLOP_1VAR_2IN_1OUT(char1, &) +DECLOP_1VAR_2IN_1OUT(char1, |) +DECLOP_1VAR_2IN_1OUT(char1, ^) +DECLOP_1VAR_2IN_1OUT(char1, <<) +DECLOP_1VAR_2IN_1OUT(char1, >>) + + +DECLOP_1VAR_ASSIGN(char1, +=) +DECLOP_1VAR_ASSIGN(char1, -=) +DECLOP_1VAR_ASSIGN(char1, *=) +DECLOP_1VAR_ASSIGN(char1, /=) +DECLOP_1VAR_ASSIGN(char1, %=) +DECLOP_1VAR_ASSIGN(char1, &=) +DECLOP_1VAR_ASSIGN(char1, |=) +DECLOP_1VAR_ASSIGN(char1, ^=) +DECLOP_1VAR_ASSIGN(char1, <<=) +DECLOP_1VAR_ASSIGN(char1, >>=) + +DECLOP_1VAR_PREOP(char1, ++) +DECLOP_1VAR_PREOP(char1, --) + +DECLOP_1VAR_POSTOP(char1, ++) +DECLOP_1VAR_POSTOP(char1, --) + +DECLOP_1VAR_COMP(char1, ==) +DECLOP_1VAR_COMP(char1, !=) +DECLOP_1VAR_COMP(char1, <) +DECLOP_1VAR_COMP(char1, >) +DECLOP_1VAR_COMP(char1, <=) +DECLOP_1VAR_COMP(char1, >=) + +DECLOP_1VAR_COMP(char1, &&) +DECLOP_1VAR_COMP(char1, ||) + +DECLOP_1VAR_1IN_1OUT(char1, ~) +DECLOP_1VAR_1IN_BOOLOUT(char1, !) + +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(char1, float) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(char1, double) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed long long) + +// SIGNED CHAR2 + +DECLOP_2VAR_2IN_1OUT(char2, +) +DECLOP_2VAR_2IN_1OUT(char2, -) +DECLOP_2VAR_2IN_1OUT(char2, *) +DECLOP_2VAR_2IN_1OUT(char2, /) +DECLOP_2VAR_2IN_1OUT(char2, %) +DECLOP_2VAR_2IN_1OUT(char2, &) +DECLOP_2VAR_2IN_1OUT(char2, |) +DECLOP_2VAR_2IN_1OUT(char2, ^) +DECLOP_2VAR_2IN_1OUT(char2, <<) +DECLOP_2VAR_2IN_1OUT(char2, >>) + +DECLOP_2VAR_ASSIGN(char2, +=) +DECLOP_2VAR_ASSIGN(char2, -=) +DECLOP_2VAR_ASSIGN(char2, *=) +DECLOP_2VAR_ASSIGN(char2, /=) +DECLOP_2VAR_ASSIGN(char2, %=) +DECLOP_2VAR_ASSIGN(char2, &=) +DECLOP_2VAR_ASSIGN(char2, |=) +DECLOP_2VAR_ASSIGN(char2, ^=) +DECLOP_2VAR_ASSIGN(char2, <<=) +DECLOP_2VAR_ASSIGN(char2, >>=) + +DECLOP_2VAR_PREOP(char2, ++) +DECLOP_2VAR_PREOP(char2, --) + +DECLOP_2VAR_POSTOP(char2, ++) +DECLOP_2VAR_POSTOP(char2, --) + +DECLOP_2VAR_COMP(char2, ==) +DECLOP_2VAR_COMP(char2, !=) +DECLOP_2VAR_COMP(char2, <) +DECLOP_2VAR_COMP(char2, >) +DECLOP_2VAR_COMP(char2, <=) +DECLOP_2VAR_COMP(char2, >=) + +DECLOP_2VAR_COMP(char2, &&) +DECLOP_2VAR_COMP(char2, ||) + +DECLOP_2VAR_1IN_1OUT(char2, ~) +DECLOP_2VAR_1IN_BOOLOUT(char2, !) + +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(char2, float) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(char2, double) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed long long) + +// SIGNED CHAR3 + +DECLOP_3VAR_2IN_1OUT(char3, +) +DECLOP_3VAR_2IN_1OUT(char3, -) +DECLOP_3VAR_2IN_1OUT(char3, *) +DECLOP_3VAR_2IN_1OUT(char3, /) +DECLOP_3VAR_2IN_1OUT(char3, %) +DECLOP_3VAR_2IN_1OUT(char3, &) +DECLOP_3VAR_2IN_1OUT(char3, |) +DECLOP_3VAR_2IN_1OUT(char3, ^) +DECLOP_3VAR_2IN_1OUT(char3, <<) +DECLOP_3VAR_2IN_1OUT(char3, >>) + +DECLOP_3VAR_ASSIGN(char3, +=) +DECLOP_3VAR_ASSIGN(char3, -=) +DECLOP_3VAR_ASSIGN(char3, *=) +DECLOP_3VAR_ASSIGN(char3, /=) +DECLOP_3VAR_ASSIGN(char3, %=) +DECLOP_3VAR_ASSIGN(char3, &=) +DECLOP_3VAR_ASSIGN(char3, |=) +DECLOP_3VAR_ASSIGN(char3, ^=) +DECLOP_3VAR_ASSIGN(char3, <<=) +DECLOP_3VAR_ASSIGN(char3, >>=) + +DECLOP_3VAR_PREOP(char3, ++) +DECLOP_3VAR_PREOP(char3, --) + +DECLOP_3VAR_POSTOP(char3, ++) +DECLOP_3VAR_POSTOP(char3, --) + +DECLOP_3VAR_COMP(char3, ==) +DECLOP_3VAR_COMP(char3, !=) +DECLOP_3VAR_COMP(char3, <) +DECLOP_3VAR_COMP(char3, >) +DECLOP_3VAR_COMP(char3, <=) +DECLOP_3VAR_COMP(char3, >=) + +DECLOP_3VAR_COMP(char3, &&) +DECLOP_3VAR_COMP(char3, ||) + +DECLOP_3VAR_1IN_1OUT(char3, ~) +DECLOP_3VAR_1IN_BOOLOUT(char3, !) + +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(char3, float) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(char3, double) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed long long) + +// SIGNED CHAR4 + +DECLOP_4VAR_2IN_1OUT(char4, +) +DECLOP_4VAR_2IN_1OUT(char4, -) +DECLOP_4VAR_2IN_1OUT(char4, *) +DECLOP_4VAR_2IN_1OUT(char4, /) +DECLOP_4VAR_2IN_1OUT(char4, %) +DECLOP_4VAR_2IN_1OUT(char4, &) +DECLOP_4VAR_2IN_1OUT(char4, |) +DECLOP_4VAR_2IN_1OUT(char4, ^) +DECLOP_4VAR_2IN_1OUT(char4, <<) +DECLOP_4VAR_2IN_1OUT(char4, >>) + +DECLOP_4VAR_ASSIGN(char4, +=) +DECLOP_4VAR_ASSIGN(char4, -=) +DECLOP_4VAR_ASSIGN(char4, *=) +DECLOP_4VAR_ASSIGN(char4, /=) +DECLOP_4VAR_ASSIGN(char4, %=) +DECLOP_4VAR_ASSIGN(char4, &=) +DECLOP_4VAR_ASSIGN(char4, |=) +DECLOP_4VAR_ASSIGN(char4, ^=) +DECLOP_4VAR_ASSIGN(char4, <<=) +DECLOP_4VAR_ASSIGN(char4, >>=) + +DECLOP_4VAR_PREOP(char4, ++) +DECLOP_4VAR_PREOP(char4, --) + +DECLOP_4VAR_POSTOP(char4, ++) +DECLOP_4VAR_POSTOP(char4, --) + +DECLOP_4VAR_COMP(char4, ==) +DECLOP_4VAR_COMP(char4, !=) +DECLOP_4VAR_COMP(char4, <) +DECLOP_4VAR_COMP(char4, >) +DECLOP_4VAR_COMP(char4, <=) +DECLOP_4VAR_COMP(char4, >=) + +DECLOP_4VAR_COMP(char4, &&) +DECLOP_4VAR_COMP(char4, ||) + +DECLOP_4VAR_1IN_1OUT(char4, ~) +DECLOP_4VAR_1IN_BOOLOUT(char4, !) + +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(char4, float) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(char4, double) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed long long) + +// UNSIGNED SHORT1 + +DECLOP_1VAR_2IN_1OUT(ushort1, +) +DECLOP_1VAR_2IN_1OUT(ushort1, -) +DECLOP_1VAR_2IN_1OUT(ushort1, *) +DECLOP_1VAR_2IN_1OUT(ushort1, /) +DECLOP_1VAR_2IN_1OUT(ushort1, %) +DECLOP_1VAR_2IN_1OUT(ushort1, &) +DECLOP_1VAR_2IN_1OUT(ushort1, |) +DECLOP_1VAR_2IN_1OUT(ushort1, ^) +DECLOP_1VAR_2IN_1OUT(ushort1, <<) +DECLOP_1VAR_2IN_1OUT(ushort1, >>) + + +DECLOP_1VAR_ASSIGN(ushort1, +=) +DECLOP_1VAR_ASSIGN(ushort1, -=) +DECLOP_1VAR_ASSIGN(ushort1, *=) +DECLOP_1VAR_ASSIGN(ushort1, /=) +DECLOP_1VAR_ASSIGN(ushort1, %=) +DECLOP_1VAR_ASSIGN(ushort1, &=) +DECLOP_1VAR_ASSIGN(ushort1, |=) +DECLOP_1VAR_ASSIGN(ushort1, ^=) +DECLOP_1VAR_ASSIGN(ushort1, <<=) +DECLOP_1VAR_ASSIGN(ushort1, >>=) + +DECLOP_1VAR_PREOP(ushort1, ++) +DECLOP_1VAR_PREOP(ushort1, --) + +DECLOP_1VAR_POSTOP(ushort1, ++) +DECLOP_1VAR_POSTOP(ushort1, --) + +DECLOP_1VAR_COMP(ushort1, ==) +DECLOP_1VAR_COMP(ushort1, !=) +DECLOP_1VAR_COMP(ushort1, <) +DECLOP_1VAR_COMP(ushort1, >) +DECLOP_1VAR_COMP(ushort1, <=) +DECLOP_1VAR_COMP(ushort1, >=) + +DECLOP_1VAR_COMP(ushort1, &&) +DECLOP_1VAR_COMP(ushort1, ||) + +DECLOP_1VAR_1IN_1OUT(ushort1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ushort1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, float) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, double) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed long long) + +// UNSIGNED SHORT2 + +DECLOP_2VAR_2IN_1OUT(ushort2, +) +DECLOP_2VAR_2IN_1OUT(ushort2, -) +DECLOP_2VAR_2IN_1OUT(ushort2, *) +DECLOP_2VAR_2IN_1OUT(ushort2, /) +DECLOP_2VAR_2IN_1OUT(ushort2, %) +DECLOP_2VAR_2IN_1OUT(ushort2, &) +DECLOP_2VAR_2IN_1OUT(ushort2, |) +DECLOP_2VAR_2IN_1OUT(ushort2, ^) +DECLOP_2VAR_2IN_1OUT(ushort2, <<) +DECLOP_2VAR_2IN_1OUT(ushort2, >>) + +DECLOP_2VAR_ASSIGN(ushort2, +=) +DECLOP_2VAR_ASSIGN(ushort2, -=) +DECLOP_2VAR_ASSIGN(ushort2, *=) +DECLOP_2VAR_ASSIGN(ushort2, /=) +DECLOP_2VAR_ASSIGN(ushort2, %=) +DECLOP_2VAR_ASSIGN(ushort2, &=) +DECLOP_2VAR_ASSIGN(ushort2, |=) +DECLOP_2VAR_ASSIGN(ushort2, ^=) +DECLOP_2VAR_ASSIGN(ushort2, <<=) +DECLOP_2VAR_ASSIGN(ushort2, >>=) + +DECLOP_2VAR_PREOP(ushort2, ++) +DECLOP_2VAR_PREOP(ushort2, --) + +DECLOP_2VAR_POSTOP(ushort2, ++) +DECLOP_2VAR_POSTOP(ushort2, --) + +DECLOP_2VAR_COMP(ushort2, ==) +DECLOP_2VAR_COMP(ushort2, !=) +DECLOP_2VAR_COMP(ushort2, <) +DECLOP_2VAR_COMP(ushort2, >) +DECLOP_2VAR_COMP(ushort2, <=) +DECLOP_2VAR_COMP(ushort2, >=) + +DECLOP_2VAR_COMP(ushort2, &&) +DECLOP_2VAR_COMP(ushort2, ||) + +DECLOP_2VAR_1IN_1OUT(ushort2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ushort2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, float) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, double) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed long long) + +// UNSIGNED SHORT3 + +DECLOP_3VAR_2IN_1OUT(ushort3, +) +DECLOP_3VAR_2IN_1OUT(ushort3, -) +DECLOP_3VAR_2IN_1OUT(ushort3, *) +DECLOP_3VAR_2IN_1OUT(ushort3, /) +DECLOP_3VAR_2IN_1OUT(ushort3, %) +DECLOP_3VAR_2IN_1OUT(ushort3, &) +DECLOP_3VAR_2IN_1OUT(ushort3, |) +DECLOP_3VAR_2IN_1OUT(ushort3, ^) +DECLOP_3VAR_2IN_1OUT(ushort3, <<) +DECLOP_3VAR_2IN_1OUT(ushort3, >>) + +DECLOP_3VAR_ASSIGN(ushort3, +=) +DECLOP_3VAR_ASSIGN(ushort3, -=) +DECLOP_3VAR_ASSIGN(ushort3, *=) +DECLOP_3VAR_ASSIGN(ushort3, /=) +DECLOP_3VAR_ASSIGN(ushort3, %=) +DECLOP_3VAR_ASSIGN(ushort3, &=) +DECLOP_3VAR_ASSIGN(ushort3, |=) +DECLOP_3VAR_ASSIGN(ushort3, ^=) +DECLOP_3VAR_ASSIGN(ushort3, <<=) +DECLOP_3VAR_ASSIGN(ushort3, >>=) + +DECLOP_3VAR_PREOP(ushort3, ++) +DECLOP_3VAR_PREOP(ushort3, --) + +DECLOP_3VAR_POSTOP(ushort3, ++) +DECLOP_3VAR_POSTOP(ushort3, --) + +DECLOP_3VAR_COMP(ushort3, ==) +DECLOP_3VAR_COMP(ushort3, !=) +DECLOP_3VAR_COMP(ushort3, <) +DECLOP_3VAR_COMP(ushort3, >) +DECLOP_3VAR_COMP(ushort3, <=) +DECLOP_3VAR_COMP(ushort3, >=) + +DECLOP_3VAR_COMP(ushort3, &&) +DECLOP_3VAR_COMP(ushort3, ||) + +DECLOP_3VAR_1IN_1OUT(ushort3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ushort3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, float) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, double) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed long long) + +// UNSIGNED SHORT4 + +DECLOP_4VAR_2IN_1OUT(ushort4, +) +DECLOP_4VAR_2IN_1OUT(ushort4, -) +DECLOP_4VAR_2IN_1OUT(ushort4, *) +DECLOP_4VAR_2IN_1OUT(ushort4, /) +DECLOP_4VAR_2IN_1OUT(ushort4, %) +DECLOP_4VAR_2IN_1OUT(ushort4, &) +DECLOP_4VAR_2IN_1OUT(ushort4, |) +DECLOP_4VAR_2IN_1OUT(ushort4, ^) +DECLOP_4VAR_2IN_1OUT(ushort4, <<) +DECLOP_4VAR_2IN_1OUT(ushort4, >>) + +DECLOP_4VAR_ASSIGN(ushort4, +=) +DECLOP_4VAR_ASSIGN(ushort4, -=) +DECLOP_4VAR_ASSIGN(ushort4, *=) +DECLOP_4VAR_ASSIGN(ushort4, /=) +DECLOP_4VAR_ASSIGN(ushort4, %=) +DECLOP_4VAR_ASSIGN(ushort4, &=) +DECLOP_4VAR_ASSIGN(ushort4, |=) +DECLOP_4VAR_ASSIGN(ushort4, ^=) +DECLOP_4VAR_ASSIGN(ushort4, <<=) +DECLOP_4VAR_ASSIGN(ushort4, >>=) + +DECLOP_4VAR_PREOP(ushort4, ++) +DECLOP_4VAR_PREOP(ushort4, --) + +DECLOP_4VAR_POSTOP(ushort4, ++) +DECLOP_4VAR_POSTOP(ushort4, --) + +DECLOP_4VAR_COMP(ushort4, ==) +DECLOP_4VAR_COMP(ushort4, !=) +DECLOP_4VAR_COMP(ushort4, <) +DECLOP_4VAR_COMP(ushort4, >) +DECLOP_4VAR_COMP(ushort4, <=) +DECLOP_4VAR_COMP(ushort4, >=) + +DECLOP_4VAR_COMP(ushort4, &&) +DECLOP_4VAR_COMP(ushort4, ||) + +DECLOP_4VAR_1IN_1OUT(ushort4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ushort4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, float) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, double) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed long long) + +// SIGNED SHORT1 + +DECLOP_1VAR_2IN_1OUT(short1, +) +DECLOP_1VAR_2IN_1OUT(short1, -) +DECLOP_1VAR_2IN_1OUT(short1, *) +DECLOP_1VAR_2IN_1OUT(short1, /) +DECLOP_1VAR_2IN_1OUT(short1, %) +DECLOP_1VAR_2IN_1OUT(short1, &) +DECLOP_1VAR_2IN_1OUT(short1, |) +DECLOP_1VAR_2IN_1OUT(short1, ^) +DECLOP_1VAR_2IN_1OUT(short1, <<) +DECLOP_1VAR_2IN_1OUT(short1, >>) + + +DECLOP_1VAR_ASSIGN(short1, +=) +DECLOP_1VAR_ASSIGN(short1, -=) +DECLOP_1VAR_ASSIGN(short1, *=) +DECLOP_1VAR_ASSIGN(short1, /=) +DECLOP_1VAR_ASSIGN(short1, %=) +DECLOP_1VAR_ASSIGN(short1, &=) +DECLOP_1VAR_ASSIGN(short1, |=) +DECLOP_1VAR_ASSIGN(short1, ^=) +DECLOP_1VAR_ASSIGN(short1, <<=) +DECLOP_1VAR_ASSIGN(short1, >>=) + +DECLOP_1VAR_PREOP(short1, ++) +DECLOP_1VAR_PREOP(short1, --) + +DECLOP_1VAR_POSTOP(short1, ++) +DECLOP_1VAR_POSTOP(short1, --) + +DECLOP_1VAR_COMP(short1, ==) +DECLOP_1VAR_COMP(short1, !=) +DECLOP_1VAR_COMP(short1, <) +DECLOP_1VAR_COMP(short1, >) +DECLOP_1VAR_COMP(short1, <=) +DECLOP_1VAR_COMP(short1, >=) + +DECLOP_1VAR_COMP(short1, &&) +DECLOP_1VAR_COMP(short1, ||) + +DECLOP_1VAR_1IN_1OUT(short1, ~) +DECLOP_1VAR_1IN_BOOLOUT(short1, !) + +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(short1, float) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(short1, double) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed long long) + +// SIGNED SHORT2 + +DECLOP_2VAR_2IN_1OUT(short2, +) +DECLOP_2VAR_2IN_1OUT(short2, -) +DECLOP_2VAR_2IN_1OUT(short2, *) +DECLOP_2VAR_2IN_1OUT(short2, /) +DECLOP_2VAR_2IN_1OUT(short2, %) +DECLOP_2VAR_2IN_1OUT(short2, &) +DECLOP_2VAR_2IN_1OUT(short2, |) +DECLOP_2VAR_2IN_1OUT(short2, ^) +DECLOP_2VAR_2IN_1OUT(short2, <<) +DECLOP_2VAR_2IN_1OUT(short2, >>) + +DECLOP_2VAR_ASSIGN(short2, +=) +DECLOP_2VAR_ASSIGN(short2, -=) +DECLOP_2VAR_ASSIGN(short2, *=) +DECLOP_2VAR_ASSIGN(short2, /=) +DECLOP_2VAR_ASSIGN(short2, %=) +DECLOP_2VAR_ASSIGN(short2, &=) +DECLOP_2VAR_ASSIGN(short2, |=) +DECLOP_2VAR_ASSIGN(short2, ^=) +DECLOP_2VAR_ASSIGN(short2, <<=) +DECLOP_2VAR_ASSIGN(short2, >>=) + +DECLOP_2VAR_PREOP(short2, ++) +DECLOP_2VAR_PREOP(short2, --) + +DECLOP_2VAR_POSTOP(short2, ++) +DECLOP_2VAR_POSTOP(short2, --) + +DECLOP_2VAR_COMP(short2, ==) +DECLOP_2VAR_COMP(short2, !=) +DECLOP_2VAR_COMP(short2, <) +DECLOP_2VAR_COMP(short2, >) +DECLOP_2VAR_COMP(short2, <=) +DECLOP_2VAR_COMP(short2, >=) + +DECLOP_2VAR_COMP(short2, &&) +DECLOP_2VAR_COMP(short2, ||) + +DECLOP_2VAR_1IN_1OUT(short2, ~) +DECLOP_2VAR_1IN_BOOLOUT(short2, !) + +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(short2, float) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(short2, double) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed long long) + +// SIGNED SHORT3 + +DECLOP_3VAR_2IN_1OUT(short3, +) +DECLOP_3VAR_2IN_1OUT(short3, -) +DECLOP_3VAR_2IN_1OUT(short3, *) +DECLOP_3VAR_2IN_1OUT(short3, /) +DECLOP_3VAR_2IN_1OUT(short3, %) +DECLOP_3VAR_2IN_1OUT(short3, &) +DECLOP_3VAR_2IN_1OUT(short3, |) +DECLOP_3VAR_2IN_1OUT(short3, ^) +DECLOP_3VAR_2IN_1OUT(short3, <<) +DECLOP_3VAR_2IN_1OUT(short3, >>) + +DECLOP_3VAR_ASSIGN(short3, +=) +DECLOP_3VAR_ASSIGN(short3, -=) +DECLOP_3VAR_ASSIGN(short3, *=) +DECLOP_3VAR_ASSIGN(short3, /=) +DECLOP_3VAR_ASSIGN(short3, %=) +DECLOP_3VAR_ASSIGN(short3, &=) +DECLOP_3VAR_ASSIGN(short3, |=) +DECLOP_3VAR_ASSIGN(short3, ^=) +DECLOP_3VAR_ASSIGN(short3, <<=) +DECLOP_3VAR_ASSIGN(short3, >>=) + +DECLOP_3VAR_PREOP(short3, ++) +DECLOP_3VAR_PREOP(short3, --) + +DECLOP_3VAR_POSTOP(short3, ++) +DECLOP_3VAR_POSTOP(short3, --) + +DECLOP_3VAR_COMP(short3, ==) +DECLOP_3VAR_COMP(short3, !=) +DECLOP_3VAR_COMP(short3, <) +DECLOP_3VAR_COMP(short3, >) +DECLOP_3VAR_COMP(short3, <=) +DECLOP_3VAR_COMP(short3, >=) + +DECLOP_3VAR_COMP(short3, &&) +DECLOP_3VAR_COMP(short3, ||) + +DECLOP_3VAR_1IN_1OUT(short3, ~) +DECLOP_3VAR_1IN_BOOLOUT(short3, !) + +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(short3, float) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(short3, double) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed long long) + +// SIGNED SHORT4 + +DECLOP_4VAR_2IN_1OUT(short4, +) +DECLOP_4VAR_2IN_1OUT(short4, -) +DECLOP_4VAR_2IN_1OUT(short4, *) +DECLOP_4VAR_2IN_1OUT(short4, /) +DECLOP_4VAR_2IN_1OUT(short4, %) +DECLOP_4VAR_2IN_1OUT(short4, &) +DECLOP_4VAR_2IN_1OUT(short4, |) +DECLOP_4VAR_2IN_1OUT(short4, ^) +DECLOP_4VAR_2IN_1OUT(short4, <<) +DECLOP_4VAR_2IN_1OUT(short4, >>) + +DECLOP_4VAR_ASSIGN(short4, +=) +DECLOP_4VAR_ASSIGN(short4, -=) +DECLOP_4VAR_ASSIGN(short4, *=) +DECLOP_4VAR_ASSIGN(short4, /=) +DECLOP_4VAR_ASSIGN(short4, %=) +DECLOP_4VAR_ASSIGN(short4, &=) +DECLOP_4VAR_ASSIGN(short4, |=) +DECLOP_4VAR_ASSIGN(short4, ^=) +DECLOP_4VAR_ASSIGN(short4, <<=) +DECLOP_4VAR_ASSIGN(short4, >>=) + +DECLOP_4VAR_PREOP(short4, ++) +DECLOP_4VAR_PREOP(short4, --) + +DECLOP_4VAR_POSTOP(short4, ++) +DECLOP_4VAR_POSTOP(short4, --) + +DECLOP_4VAR_COMP(short4, ==) +DECLOP_4VAR_COMP(short4, !=) +DECLOP_4VAR_COMP(short4, <) +DECLOP_4VAR_COMP(short4, >) +DECLOP_4VAR_COMP(short4, <=) +DECLOP_4VAR_COMP(short4, >=) + +DECLOP_4VAR_COMP(short4, &&) +DECLOP_4VAR_COMP(short4, ||) + +DECLOP_4VAR_1IN_1OUT(short4, ~) +DECLOP_4VAR_1IN_BOOLOUT(short4, !) + +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(short4, float) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(short4, double) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed long long) + +// UNSIGNED INT1 + +DECLOP_1VAR_2IN_1OUT(uint1, +) +DECLOP_1VAR_2IN_1OUT(uint1, -) +DECLOP_1VAR_2IN_1OUT(uint1, *) +DECLOP_1VAR_2IN_1OUT(uint1, /) +DECLOP_1VAR_2IN_1OUT(uint1, %) +DECLOP_1VAR_2IN_1OUT(uint1, &) +DECLOP_1VAR_2IN_1OUT(uint1, |) +DECLOP_1VAR_2IN_1OUT(uint1, ^) +DECLOP_1VAR_2IN_1OUT(uint1, <<) +DECLOP_1VAR_2IN_1OUT(uint1, >>) + + +DECLOP_1VAR_ASSIGN(uint1, +=) +DECLOP_1VAR_ASSIGN(uint1, -=) +DECLOP_1VAR_ASSIGN(uint1, *=) +DECLOP_1VAR_ASSIGN(uint1, /=) +DECLOP_1VAR_ASSIGN(uint1, %=) +DECLOP_1VAR_ASSIGN(uint1, &=) +DECLOP_1VAR_ASSIGN(uint1, |=) +DECLOP_1VAR_ASSIGN(uint1, ^=) +DECLOP_1VAR_ASSIGN(uint1, <<=) +DECLOP_1VAR_ASSIGN(uint1, >>=) + +DECLOP_1VAR_PREOP(uint1, ++) +DECLOP_1VAR_PREOP(uint1, --) + +DECLOP_1VAR_POSTOP(uint1, ++) +DECLOP_1VAR_POSTOP(uint1, --) + +DECLOP_1VAR_COMP(uint1, ==) +DECLOP_1VAR_COMP(uint1, !=) +DECLOP_1VAR_COMP(uint1, <) +DECLOP_1VAR_COMP(uint1, >) +DECLOP_1VAR_COMP(uint1, <=) +DECLOP_1VAR_COMP(uint1, >=) + +DECLOP_1VAR_COMP(uint1, &&) +DECLOP_1VAR_COMP(uint1, ||) + +DECLOP_1VAR_1IN_1OUT(uint1, ~) +DECLOP_1VAR_1IN_BOOLOUT(uint1, !) + +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(uint1, float) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, double) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed long long) + +// UNSIGNED INT2 + +DECLOP_2VAR_2IN_1OUT(uint2, +) +DECLOP_2VAR_2IN_1OUT(uint2, -) +DECLOP_2VAR_2IN_1OUT(uint2, *) +DECLOP_2VAR_2IN_1OUT(uint2, /) +DECLOP_2VAR_2IN_1OUT(uint2, %) +DECLOP_2VAR_2IN_1OUT(uint2, &) +DECLOP_2VAR_2IN_1OUT(uint2, |) +DECLOP_2VAR_2IN_1OUT(uint2, ^) +DECLOP_2VAR_2IN_1OUT(uint2, <<) +DECLOP_2VAR_2IN_1OUT(uint2, >>) + +DECLOP_2VAR_ASSIGN(uint2, +=) +DECLOP_2VAR_ASSIGN(uint2, -=) +DECLOP_2VAR_ASSIGN(uint2, *=) +DECLOP_2VAR_ASSIGN(uint2, /=) +DECLOP_2VAR_ASSIGN(uint2, %=) +DECLOP_2VAR_ASSIGN(uint2, &=) +DECLOP_2VAR_ASSIGN(uint2, |=) +DECLOP_2VAR_ASSIGN(uint2, ^=) +DECLOP_2VAR_ASSIGN(uint2, <<=) +DECLOP_2VAR_ASSIGN(uint2, >>=) + +DECLOP_2VAR_PREOP(uint2, ++) +DECLOP_2VAR_PREOP(uint2, --) + +DECLOP_2VAR_POSTOP(uint2, ++) +DECLOP_2VAR_POSTOP(uint2, --) + +DECLOP_2VAR_COMP(uint2, ==) +DECLOP_2VAR_COMP(uint2, !=) +DECLOP_2VAR_COMP(uint2, <) +DECLOP_2VAR_COMP(uint2, >) +DECLOP_2VAR_COMP(uint2, <=) +DECLOP_2VAR_COMP(uint2, >=) + +DECLOP_2VAR_COMP(uint2, &&) +DECLOP_2VAR_COMP(uint2, ||) + +DECLOP_2VAR_1IN_1OUT(uint2, ~) +DECLOP_2VAR_1IN_BOOLOUT(uint2, !) + +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(uint2, float) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, double) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed long long) + +// UNSIGNED INT3 + +DECLOP_3VAR_2IN_1OUT(uint3, +) +DECLOP_3VAR_2IN_1OUT(uint3, -) +DECLOP_3VAR_2IN_1OUT(uint3, *) +DECLOP_3VAR_2IN_1OUT(uint3, /) +DECLOP_3VAR_2IN_1OUT(uint3, %) +DECLOP_3VAR_2IN_1OUT(uint3, &) +DECLOP_3VAR_2IN_1OUT(uint3, |) +DECLOP_3VAR_2IN_1OUT(uint3, ^) +DECLOP_3VAR_2IN_1OUT(uint3, <<) +DECLOP_3VAR_2IN_1OUT(uint3, >>) + +DECLOP_3VAR_ASSIGN(uint3, +=) +DECLOP_3VAR_ASSIGN(uint3, -=) +DECLOP_3VAR_ASSIGN(uint3, *=) +DECLOP_3VAR_ASSIGN(uint3, /=) +DECLOP_3VAR_ASSIGN(uint3, %=) +DECLOP_3VAR_ASSIGN(uint3, &=) +DECLOP_3VAR_ASSIGN(uint3, |=) +DECLOP_3VAR_ASSIGN(uint3, ^=) +DECLOP_3VAR_ASSIGN(uint3, <<=) +DECLOP_3VAR_ASSIGN(uint3, >>=) + +DECLOP_3VAR_PREOP(uint3, ++) +DECLOP_3VAR_PREOP(uint3, --) + +DECLOP_3VAR_POSTOP(uint3, ++) +DECLOP_3VAR_POSTOP(uint3, --) + +DECLOP_3VAR_COMP(uint3, ==) +DECLOP_3VAR_COMP(uint3, !=) +DECLOP_3VAR_COMP(uint3, <) +DECLOP_3VAR_COMP(uint3, >) +DECLOP_3VAR_COMP(uint3, <=) +DECLOP_3VAR_COMP(uint3, >=) + +DECLOP_3VAR_COMP(uint3, &&) +DECLOP_3VAR_COMP(uint3, ||) + +DECLOP_3VAR_1IN_1OUT(uint3, ~) +DECLOP_3VAR_1IN_BOOLOUT(uint3, !) + +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(uint3, float) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, double) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed long long) + +// UNSIGNED INT4 + +DECLOP_4VAR_2IN_1OUT(uint4, +) +DECLOP_4VAR_2IN_1OUT(uint4, -) +DECLOP_4VAR_2IN_1OUT(uint4, *) +DECLOP_4VAR_2IN_1OUT(uint4, /) +DECLOP_4VAR_2IN_1OUT(uint4, %) +DECLOP_4VAR_2IN_1OUT(uint4, &) +DECLOP_4VAR_2IN_1OUT(uint4, |) +DECLOP_4VAR_2IN_1OUT(uint4, ^) +DECLOP_4VAR_2IN_1OUT(uint4, <<) +DECLOP_4VAR_2IN_1OUT(uint4, >>) + +DECLOP_4VAR_ASSIGN(uint4, +=) +DECLOP_4VAR_ASSIGN(uint4, -=) +DECLOP_4VAR_ASSIGN(uint4, *=) +DECLOP_4VAR_ASSIGN(uint4, /=) +DECLOP_4VAR_ASSIGN(uint4, %=) +DECLOP_4VAR_ASSIGN(uint4, &=) +DECLOP_4VAR_ASSIGN(uint4, |=) +DECLOP_4VAR_ASSIGN(uint4, ^=) +DECLOP_4VAR_ASSIGN(uint4, <<=) +DECLOP_4VAR_ASSIGN(uint4, >>=) + +DECLOP_4VAR_PREOP(uint4, ++) +DECLOP_4VAR_PREOP(uint4, --) + +DECLOP_4VAR_POSTOP(uint4, ++) +DECLOP_4VAR_POSTOP(uint4, --) + +DECLOP_4VAR_COMP(uint4, ==) +DECLOP_4VAR_COMP(uint4, !=) +DECLOP_4VAR_COMP(uint4, <) +DECLOP_4VAR_COMP(uint4, >) +DECLOP_4VAR_COMP(uint4, <=) +DECLOP_4VAR_COMP(uint4, >=) + +DECLOP_4VAR_COMP(uint4, &&) +DECLOP_4VAR_COMP(uint4, ||) + +DECLOP_4VAR_1IN_1OUT(uint4, ~) +DECLOP_4VAR_1IN_BOOLOUT(uint4, !) + +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(uint4, float) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, double) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed long long) + +// SIGNED INT1 + +DECLOP_1VAR_2IN_1OUT(int1, +) +DECLOP_1VAR_2IN_1OUT(int1, -) +DECLOP_1VAR_2IN_1OUT(int1, *) +DECLOP_1VAR_2IN_1OUT(int1, /) +DECLOP_1VAR_2IN_1OUT(int1, %) +DECLOP_1VAR_2IN_1OUT(int1, &) +DECLOP_1VAR_2IN_1OUT(int1, |) +DECLOP_1VAR_2IN_1OUT(int1, ^) +DECLOP_1VAR_2IN_1OUT(int1, <<) +DECLOP_1VAR_2IN_1OUT(int1, >>) + + +DECLOP_1VAR_ASSIGN(int1, +=) +DECLOP_1VAR_ASSIGN(int1, -=) +DECLOP_1VAR_ASSIGN(int1, *=) +DECLOP_1VAR_ASSIGN(int1, /=) +DECLOP_1VAR_ASSIGN(int1, %=) +DECLOP_1VAR_ASSIGN(int1, &=) +DECLOP_1VAR_ASSIGN(int1, |=) +DECLOP_1VAR_ASSIGN(int1, ^=) +DECLOP_1VAR_ASSIGN(int1, <<=) +DECLOP_1VAR_ASSIGN(int1, >>=) + +DECLOP_1VAR_PREOP(int1, ++) +DECLOP_1VAR_PREOP(int1, --) + +DECLOP_1VAR_POSTOP(int1, ++) +DECLOP_1VAR_POSTOP(int1, --) + +DECLOP_1VAR_COMP(int1, ==) +DECLOP_1VAR_COMP(int1, !=) +DECLOP_1VAR_COMP(int1, <) +DECLOP_1VAR_COMP(int1, >) +DECLOP_1VAR_COMP(int1, <=) +DECLOP_1VAR_COMP(int1, >=) + +DECLOP_1VAR_COMP(int1, &&) +DECLOP_1VAR_COMP(int1, ||) + +DECLOP_1VAR_1IN_1OUT(int1, ~) +DECLOP_1VAR_1IN_BOOLOUT(int1, !) + +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(int1, float) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(int1, double) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed long long) + +// SIGNED INT2 + +DECLOP_2VAR_2IN_1OUT(int2, +) +DECLOP_2VAR_2IN_1OUT(int2, -) +DECLOP_2VAR_2IN_1OUT(int2, *) +DECLOP_2VAR_2IN_1OUT(int2, /) +DECLOP_2VAR_2IN_1OUT(int2, %) +DECLOP_2VAR_2IN_1OUT(int2, &) +DECLOP_2VAR_2IN_1OUT(int2, |) +DECLOP_2VAR_2IN_1OUT(int2, ^) +DECLOP_2VAR_2IN_1OUT(int2, <<) +DECLOP_2VAR_2IN_1OUT(int2, >>) + +DECLOP_2VAR_ASSIGN(int2, +=) +DECLOP_2VAR_ASSIGN(int2, -=) +DECLOP_2VAR_ASSIGN(int2, *=) +DECLOP_2VAR_ASSIGN(int2, /=) +DECLOP_2VAR_ASSIGN(int2, %=) +DECLOP_2VAR_ASSIGN(int2, &=) +DECLOP_2VAR_ASSIGN(int2, |=) +DECLOP_2VAR_ASSIGN(int2, ^=) +DECLOP_2VAR_ASSIGN(int2, <<=) +DECLOP_2VAR_ASSIGN(int2, >>=) + +DECLOP_2VAR_PREOP(int2, ++) +DECLOP_2VAR_PREOP(int2, --) + +DECLOP_2VAR_POSTOP(int2, ++) +DECLOP_2VAR_POSTOP(int2, --) + +DECLOP_2VAR_COMP(int2, ==) +DECLOP_2VAR_COMP(int2, !=) +DECLOP_2VAR_COMP(int2, <) +DECLOP_2VAR_COMP(int2, >) +DECLOP_2VAR_COMP(int2, <=) +DECLOP_2VAR_COMP(int2, >=) + +DECLOP_2VAR_COMP(int2, &&) +DECLOP_2VAR_COMP(int2, ||) + +DECLOP_2VAR_1IN_1OUT(int2, ~) +DECLOP_2VAR_1IN_BOOLOUT(int2, !) + +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(int2, float) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(int2, double) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed long long) + +// SIGNED INT3 + +DECLOP_3VAR_2IN_1OUT(int3, +) +DECLOP_3VAR_2IN_1OUT(int3, -) +DECLOP_3VAR_2IN_1OUT(int3, *) +DECLOP_3VAR_2IN_1OUT(int3, /) +DECLOP_3VAR_2IN_1OUT(int3, %) +DECLOP_3VAR_2IN_1OUT(int3, &) +DECLOP_3VAR_2IN_1OUT(int3, |) +DECLOP_3VAR_2IN_1OUT(int3, ^) +DECLOP_3VAR_2IN_1OUT(int3, <<) +DECLOP_3VAR_2IN_1OUT(int3, >>) + +DECLOP_3VAR_ASSIGN(int3, +=) +DECLOP_3VAR_ASSIGN(int3, -=) +DECLOP_3VAR_ASSIGN(int3, *=) +DECLOP_3VAR_ASSIGN(int3, /=) +DECLOP_3VAR_ASSIGN(int3, %=) +DECLOP_3VAR_ASSIGN(int3, &=) +DECLOP_3VAR_ASSIGN(int3, |=) +DECLOP_3VAR_ASSIGN(int3, ^=) +DECLOP_3VAR_ASSIGN(int3, <<=) +DECLOP_3VAR_ASSIGN(int3, >>=) + +DECLOP_3VAR_PREOP(int3, ++) +DECLOP_3VAR_PREOP(int3, --) + +DECLOP_3VAR_POSTOP(int3, ++) +DECLOP_3VAR_POSTOP(int3, --) + +DECLOP_3VAR_COMP(int3, ==) +DECLOP_3VAR_COMP(int3, !=) +DECLOP_3VAR_COMP(int3, <) +DECLOP_3VAR_COMP(int3, >) +DECLOP_3VAR_COMP(int3, <=) +DECLOP_3VAR_COMP(int3, >=) + +DECLOP_3VAR_COMP(int3, &&) +DECLOP_3VAR_COMP(int3, ||) + +DECLOP_3VAR_1IN_1OUT(int3, ~) +DECLOP_3VAR_1IN_BOOLOUT(int3, !) + +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(int3, float) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(int3, double) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed long long) + +// SIGNED INT4 + +DECLOP_4VAR_2IN_1OUT(int4, +) +DECLOP_4VAR_2IN_1OUT(int4, -) +DECLOP_4VAR_2IN_1OUT(int4, *) +DECLOP_4VAR_2IN_1OUT(int4, /) +DECLOP_4VAR_2IN_1OUT(int4, %) +DECLOP_4VAR_2IN_1OUT(int4, &) +DECLOP_4VAR_2IN_1OUT(int4, |) +DECLOP_4VAR_2IN_1OUT(int4, ^) +DECLOP_4VAR_2IN_1OUT(int4, <<) +DECLOP_4VAR_2IN_1OUT(int4, >>) + +DECLOP_4VAR_ASSIGN(int4, +=) +DECLOP_4VAR_ASSIGN(int4, -=) +DECLOP_4VAR_ASSIGN(int4, *=) +DECLOP_4VAR_ASSIGN(int4, /=) +DECLOP_4VAR_ASSIGN(int4, %=) +DECLOP_4VAR_ASSIGN(int4, &=) +DECLOP_4VAR_ASSIGN(int4, |=) +DECLOP_4VAR_ASSIGN(int4, ^=) +DECLOP_4VAR_ASSIGN(int4, <<=) +DECLOP_4VAR_ASSIGN(int4, >>=) + +DECLOP_4VAR_PREOP(int4, ++) +DECLOP_4VAR_PREOP(int4, --) + +DECLOP_4VAR_POSTOP(int4, ++) +DECLOP_4VAR_POSTOP(int4, --) + +DECLOP_4VAR_COMP(int4, ==) +DECLOP_4VAR_COMP(int4, !=) +DECLOP_4VAR_COMP(int4, <) +DECLOP_4VAR_COMP(int4, >) +DECLOP_4VAR_COMP(int4, <=) +DECLOP_4VAR_COMP(int4, >=) + +DECLOP_4VAR_COMP(int4, &&) +DECLOP_4VAR_COMP(int4, ||) + +DECLOP_4VAR_1IN_1OUT(int4, ~) +DECLOP_4VAR_1IN_BOOLOUT(int4, !) + +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(int4, float) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(int4, double) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed long long) + +// FLOAT1 + +DECLOP_1VAR_2IN_1OUT(float1, +) +DECLOP_1VAR_2IN_1OUT(float1, -) +DECLOP_1VAR_2IN_1OUT(float1, *) +DECLOP_1VAR_2IN_1OUT(float1, /) + +DECLOP_1VAR_ASSIGN(float1, +=) +DECLOP_1VAR_ASSIGN(float1, -=) +DECLOP_1VAR_ASSIGN(float1, *=) +DECLOP_1VAR_ASSIGN(float1, /=) + +DECLOP_1VAR_PREOP(float1, ++) +DECLOP_1VAR_PREOP(float1, --) + +DECLOP_1VAR_POSTOP(float1, ++) +DECLOP_1VAR_POSTOP(float1, --) + +DECLOP_1VAR_COMP(float1, ==) +DECLOP_1VAR_COMP(float1, !=) +DECLOP_1VAR_COMP(float1, <) +DECLOP_1VAR_COMP(float1, >) +DECLOP_1VAR_COMP(float1, <=) +DECLOP_1VAR_COMP(float1, >=) + +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(float1, float) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(float1, double) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed long long) + +// FLOAT2 + +DECLOP_2VAR_2IN_1OUT(float2, +) +DECLOP_2VAR_2IN_1OUT(float2, -) +DECLOP_2VAR_2IN_1OUT(float2, *) +DECLOP_2VAR_2IN_1OUT(float2, /) + +DECLOP_2VAR_ASSIGN(float2, +=) +DECLOP_2VAR_ASSIGN(float2, -=) +DECLOP_2VAR_ASSIGN(float2, *=) +DECLOP_2VAR_ASSIGN(float2, /=) + +DECLOP_2VAR_PREOP(float2, ++) +DECLOP_2VAR_PREOP(float2, --) + +DECLOP_2VAR_POSTOP(float2, ++) +DECLOP_2VAR_POSTOP(float2, --) + +DECLOP_2VAR_COMP(float2, ==) +DECLOP_2VAR_COMP(float2, !=) +DECLOP_2VAR_COMP(float2, <) +DECLOP_2VAR_COMP(float2, >) +DECLOP_2VAR_COMP(float2, <=) +DECLOP_2VAR_COMP(float2, >=) + +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(float2, float) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(float2, double) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed long long) + +// FLOAT3 + +DECLOP_3VAR_2IN_1OUT(float3, +) +DECLOP_3VAR_2IN_1OUT(float3, -) +DECLOP_3VAR_2IN_1OUT(float3, *) +DECLOP_3VAR_2IN_1OUT(float3, /) + +DECLOP_3VAR_ASSIGN(float3, +=) +DECLOP_3VAR_ASSIGN(float3, -=) +DECLOP_3VAR_ASSIGN(float3, *=) +DECLOP_3VAR_ASSIGN(float3, /=) + +DECLOP_3VAR_PREOP(float3, ++) +DECLOP_3VAR_PREOP(float3, --) + +DECLOP_3VAR_POSTOP(float3, ++) +DECLOP_3VAR_POSTOP(float3, --) + +DECLOP_3VAR_COMP(float3, ==) +DECLOP_3VAR_COMP(float3, !=) +DECLOP_3VAR_COMP(float3, <) +DECLOP_3VAR_COMP(float3, >) +DECLOP_3VAR_COMP(float3, <=) +DECLOP_3VAR_COMP(float3, >=) + +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(float3, float) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(float3, double) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed long long) + +// FLOAT4 + +DECLOP_4VAR_2IN_1OUT(float4, +) +DECLOP_4VAR_2IN_1OUT(float4, -) +DECLOP_4VAR_2IN_1OUT(float4, *) +DECLOP_4VAR_2IN_1OUT(float4, /) + +DECLOP_4VAR_ASSIGN(float4, +=) +DECLOP_4VAR_ASSIGN(float4, -=) +DECLOP_4VAR_ASSIGN(float4, *=) +DECLOP_4VAR_ASSIGN(float4, /=) + +DECLOP_4VAR_PREOP(float4, ++) +DECLOP_4VAR_PREOP(float4, --) + +DECLOP_4VAR_POSTOP(float4, ++) +DECLOP_4VAR_POSTOP(float4, --) + +DECLOP_4VAR_COMP(float4, ==) +DECLOP_4VAR_COMP(float4, !=) +DECLOP_4VAR_COMP(float4, <) +DECLOP_4VAR_COMP(float4, >) +DECLOP_4VAR_COMP(float4, <=) +DECLOP_4VAR_COMP(float4, >=) + +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(float4, float) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(float4, double) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed long long) + +// DOUBLE1 + +DECLOP_1VAR_2IN_1OUT(double1, +) +DECLOP_1VAR_2IN_1OUT(double1, -) +DECLOP_1VAR_2IN_1OUT(double1, *) +DECLOP_1VAR_2IN_1OUT(double1, /) + +DECLOP_1VAR_ASSIGN(double1, +=) +DECLOP_1VAR_ASSIGN(double1, -=) +DECLOP_1VAR_ASSIGN(double1, *=) +DECLOP_1VAR_ASSIGN(double1, /=) + +DECLOP_1VAR_PREOP(double1, ++) +DECLOP_1VAR_PREOP(double1, --) + +DECLOP_1VAR_POSTOP(double1, ++) +DECLOP_1VAR_POSTOP(double1, --) + +DECLOP_1VAR_COMP(double1, ==) +DECLOP_1VAR_COMP(double1, !=) +DECLOP_1VAR_COMP(double1, <) +DECLOP_1VAR_COMP(double1, >) +DECLOP_1VAR_COMP(double1, <=) +DECLOP_1VAR_COMP(double1, >=) + +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(double1, float) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(double1, double) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed long long) + +// DOUBLE2 + +DECLOP_2VAR_2IN_1OUT(double2, +) +DECLOP_2VAR_2IN_1OUT(double2, -) +DECLOP_2VAR_2IN_1OUT(double2, *) +DECLOP_2VAR_2IN_1OUT(double2, /) + +DECLOP_2VAR_ASSIGN(double2, +=) +DECLOP_2VAR_ASSIGN(double2, -=) +DECLOP_2VAR_ASSIGN(double2, *=) +DECLOP_2VAR_ASSIGN(double2, /=) + +DECLOP_2VAR_PREOP(double2, ++) +DECLOP_2VAR_PREOP(double2, --) + +DECLOP_2VAR_POSTOP(double2, ++) +DECLOP_2VAR_POSTOP(double2, --) + +DECLOP_2VAR_COMP(double2, ==) +DECLOP_2VAR_COMP(double2, !=) +DECLOP_2VAR_COMP(double2, <) +DECLOP_2VAR_COMP(double2, >) +DECLOP_2VAR_COMP(double2, <=) +DECLOP_2VAR_COMP(double2, >=) + +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(double2, float) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(double2, double) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed long long) + +// DOUBLE3 + +DECLOP_3VAR_2IN_1OUT(double3, +) +DECLOP_3VAR_2IN_1OUT(double3, -) +DECLOP_3VAR_2IN_1OUT(double3, *) +DECLOP_3VAR_2IN_1OUT(double3, /) + +DECLOP_3VAR_ASSIGN(double3, +=) +DECLOP_3VAR_ASSIGN(double3, -=) +DECLOP_3VAR_ASSIGN(double3, *=) +DECLOP_3VAR_ASSIGN(double3, /=) + +DECLOP_3VAR_PREOP(double3, ++) +DECLOP_3VAR_PREOP(double3, --) + +DECLOP_3VAR_POSTOP(double3, ++) +DECLOP_3VAR_POSTOP(double3, --) + +DECLOP_3VAR_COMP(double3, ==) +DECLOP_3VAR_COMP(double3, !=) +DECLOP_3VAR_COMP(double3, <) +DECLOP_3VAR_COMP(double3, >) +DECLOP_3VAR_COMP(double3, <=) +DECLOP_3VAR_COMP(double3, >=) + +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(double3, float) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(double3, double) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed long long) + +// DOUBLE4 + +DECLOP_4VAR_2IN_1OUT(double4, +) +DECLOP_4VAR_2IN_1OUT(double4, -) +DECLOP_4VAR_2IN_1OUT(double4, *) +DECLOP_4VAR_2IN_1OUT(double4, /) + +DECLOP_4VAR_ASSIGN(double4, +=) +DECLOP_4VAR_ASSIGN(double4, -=) +DECLOP_4VAR_ASSIGN(double4, *=) +DECLOP_4VAR_ASSIGN(double4, /=) + +DECLOP_4VAR_PREOP(double4, ++) +DECLOP_4VAR_PREOP(double4, --) + +DECLOP_4VAR_POSTOP(double4, ++) +DECLOP_4VAR_POSTOP(double4, --) + +DECLOP_4VAR_COMP(double4, ==) +DECLOP_4VAR_COMP(double4, !=) +DECLOP_4VAR_COMP(double4, <) +DECLOP_4VAR_COMP(double4, >) +DECLOP_4VAR_COMP(double4, <=) +DECLOP_4VAR_COMP(double4, >=) + +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(double4, float) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(double4, double) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed long long) + +// UNSIGNED LONG1 + +DECLOP_1VAR_2IN_1OUT(ulong1, +) +DECLOP_1VAR_2IN_1OUT(ulong1, -) +DECLOP_1VAR_2IN_1OUT(ulong1, *) +DECLOP_1VAR_2IN_1OUT(ulong1, /) +DECLOP_1VAR_2IN_1OUT(ulong1, %) +DECLOP_1VAR_2IN_1OUT(ulong1, &) +DECLOP_1VAR_2IN_1OUT(ulong1, |) +DECLOP_1VAR_2IN_1OUT(ulong1, ^) +DECLOP_1VAR_2IN_1OUT(ulong1, <<) +DECLOP_1VAR_2IN_1OUT(ulong1, >>) + + +DECLOP_1VAR_ASSIGN(ulong1, +=) +DECLOP_1VAR_ASSIGN(ulong1, -=) +DECLOP_1VAR_ASSIGN(ulong1, *=) +DECLOP_1VAR_ASSIGN(ulong1, /=) +DECLOP_1VAR_ASSIGN(ulong1, %=) +DECLOP_1VAR_ASSIGN(ulong1, &=) +DECLOP_1VAR_ASSIGN(ulong1, |=) +DECLOP_1VAR_ASSIGN(ulong1, ^=) +DECLOP_1VAR_ASSIGN(ulong1, <<=) +DECLOP_1VAR_ASSIGN(ulong1, >>=) + +DECLOP_1VAR_PREOP(ulong1, ++) +DECLOP_1VAR_PREOP(ulong1, --) + +DECLOP_1VAR_POSTOP(ulong1, ++) +DECLOP_1VAR_POSTOP(ulong1, --) + +DECLOP_1VAR_COMP(ulong1, ==) +DECLOP_1VAR_COMP(ulong1, !=) +DECLOP_1VAR_COMP(ulong1, <) +DECLOP_1VAR_COMP(ulong1, >) +DECLOP_1VAR_COMP(ulong1, <=) +DECLOP_1VAR_COMP(ulong1, >=) + +DECLOP_1VAR_COMP(ulong1, &&) +DECLOP_1VAR_COMP(ulong1, ||) + +DECLOP_1VAR_1IN_1OUT(ulong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ulong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, float) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, double) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed long long) + +// UNSIGNED LONG2 + +DECLOP_2VAR_2IN_1OUT(ulong2, +) +DECLOP_2VAR_2IN_1OUT(ulong2, -) +DECLOP_2VAR_2IN_1OUT(ulong2, *) +DECLOP_2VAR_2IN_1OUT(ulong2, /) +DECLOP_2VAR_2IN_1OUT(ulong2, %) +DECLOP_2VAR_2IN_1OUT(ulong2, &) +DECLOP_2VAR_2IN_1OUT(ulong2, |) +DECLOP_2VAR_2IN_1OUT(ulong2, ^) +DECLOP_2VAR_2IN_1OUT(ulong2, <<) +DECLOP_2VAR_2IN_1OUT(ulong2, >>) + +DECLOP_2VAR_ASSIGN(ulong2, +=) +DECLOP_2VAR_ASSIGN(ulong2, -=) +DECLOP_2VAR_ASSIGN(ulong2, *=) +DECLOP_2VAR_ASSIGN(ulong2, /=) +DECLOP_2VAR_ASSIGN(ulong2, %=) +DECLOP_2VAR_ASSIGN(ulong2, &=) +DECLOP_2VAR_ASSIGN(ulong2, |=) +DECLOP_2VAR_ASSIGN(ulong2, ^=) +DECLOP_2VAR_ASSIGN(ulong2, <<=) +DECLOP_2VAR_ASSIGN(ulong2, >>=) + +DECLOP_2VAR_PREOP(ulong2, ++) +DECLOP_2VAR_PREOP(ulong2, --) + +DECLOP_2VAR_POSTOP(ulong2, ++) +DECLOP_2VAR_POSTOP(ulong2, --) + +DECLOP_2VAR_COMP(ulong2, ==) +DECLOP_2VAR_COMP(ulong2, !=) +DECLOP_2VAR_COMP(ulong2, <) +DECLOP_2VAR_COMP(ulong2, >) +DECLOP_2VAR_COMP(ulong2, <=) +DECLOP_2VAR_COMP(ulong2, >=) + +DECLOP_2VAR_COMP(ulong2, &&) +DECLOP_2VAR_COMP(ulong2, ||) + +DECLOP_2VAR_1IN_1OUT(ulong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ulong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, float) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, double) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed long long) + +// UNSIGNED LONG3 + +DECLOP_3VAR_2IN_1OUT(ulong3, +) +DECLOP_3VAR_2IN_1OUT(ulong3, -) +DECLOP_3VAR_2IN_1OUT(ulong3, *) +DECLOP_3VAR_2IN_1OUT(ulong3, /) +DECLOP_3VAR_2IN_1OUT(ulong3, %) +DECLOP_3VAR_2IN_1OUT(ulong3, &) +DECLOP_3VAR_2IN_1OUT(ulong3, |) +DECLOP_3VAR_2IN_1OUT(ulong3, ^) +DECLOP_3VAR_2IN_1OUT(ulong3, <<) +DECLOP_3VAR_2IN_1OUT(ulong3, >>) + +DECLOP_3VAR_ASSIGN(ulong3, +=) +DECLOP_3VAR_ASSIGN(ulong3, -=) +DECLOP_3VAR_ASSIGN(ulong3, *=) +DECLOP_3VAR_ASSIGN(ulong3, /=) +DECLOP_3VAR_ASSIGN(ulong3, %=) +DECLOP_3VAR_ASSIGN(ulong3, &=) +DECLOP_3VAR_ASSIGN(ulong3, |=) +DECLOP_3VAR_ASSIGN(ulong3, ^=) +DECLOP_3VAR_ASSIGN(ulong3, <<=) +DECLOP_3VAR_ASSIGN(ulong3, >>=) + +DECLOP_3VAR_PREOP(ulong3, ++) +DECLOP_3VAR_PREOP(ulong3, --) + +DECLOP_3VAR_POSTOP(ulong3, ++) +DECLOP_3VAR_POSTOP(ulong3, --) + +DECLOP_3VAR_COMP(ulong3, ==) +DECLOP_3VAR_COMP(ulong3, !=) +DECLOP_3VAR_COMP(ulong3, <) +DECLOP_3VAR_COMP(ulong3, >) +DECLOP_3VAR_COMP(ulong3, <=) +DECLOP_3VAR_COMP(ulong3, >=) + +DECLOP_3VAR_COMP(ulong3, &&) +DECLOP_3VAR_COMP(ulong3, ||) + +DECLOP_3VAR_1IN_1OUT(ulong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ulong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, float) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, double) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed long long) + +// UNSIGNED LONG4 + +DECLOP_4VAR_2IN_1OUT(ulong4, +) +DECLOP_4VAR_2IN_1OUT(ulong4, -) +DECLOP_4VAR_2IN_1OUT(ulong4, *) +DECLOP_4VAR_2IN_1OUT(ulong4, /) +DECLOP_4VAR_2IN_1OUT(ulong4, %) +DECLOP_4VAR_2IN_1OUT(ulong4, &) +DECLOP_4VAR_2IN_1OUT(ulong4, |) +DECLOP_4VAR_2IN_1OUT(ulong4, ^) +DECLOP_4VAR_2IN_1OUT(ulong4, <<) +DECLOP_4VAR_2IN_1OUT(ulong4, >>) + +DECLOP_4VAR_ASSIGN(ulong4, +=) +DECLOP_4VAR_ASSIGN(ulong4, -=) +DECLOP_4VAR_ASSIGN(ulong4, *=) +DECLOP_4VAR_ASSIGN(ulong4, /=) +DECLOP_4VAR_ASSIGN(ulong4, %=) +DECLOP_4VAR_ASSIGN(ulong4, &=) +DECLOP_4VAR_ASSIGN(ulong4, |=) +DECLOP_4VAR_ASSIGN(ulong4, ^=) +DECLOP_4VAR_ASSIGN(ulong4, <<=) +DECLOP_4VAR_ASSIGN(ulong4, >>=) + +DECLOP_4VAR_PREOP(ulong4, ++) +DECLOP_4VAR_PREOP(ulong4, --) + +DECLOP_4VAR_POSTOP(ulong4, ++) +DECLOP_4VAR_POSTOP(ulong4, --) + +DECLOP_4VAR_COMP(ulong4, ==) +DECLOP_4VAR_COMP(ulong4, !=) +DECLOP_4VAR_COMP(ulong4, <) +DECLOP_4VAR_COMP(ulong4, >) +DECLOP_4VAR_COMP(ulong4, <=) +DECLOP_4VAR_COMP(ulong4, >=) + +DECLOP_4VAR_COMP(ulong4, &&) +DECLOP_4VAR_COMP(ulong4, ||) + +DECLOP_4VAR_1IN_1OUT(ulong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ulong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, float) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, double) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed long long) + +// SIGNED LONG1 + +DECLOP_1VAR_2IN_1OUT(long1, +) +DECLOP_1VAR_2IN_1OUT(long1, -) +DECLOP_1VAR_2IN_1OUT(long1, *) +DECLOP_1VAR_2IN_1OUT(long1, /) +DECLOP_1VAR_2IN_1OUT(long1, %) +DECLOP_1VAR_2IN_1OUT(long1, &) +DECLOP_1VAR_2IN_1OUT(long1, |) +DECLOP_1VAR_2IN_1OUT(long1, ^) +DECLOP_1VAR_2IN_1OUT(long1, <<) +DECLOP_1VAR_2IN_1OUT(long1, >>) + + +DECLOP_1VAR_ASSIGN(long1, +=) +DECLOP_1VAR_ASSIGN(long1, -=) +DECLOP_1VAR_ASSIGN(long1, *=) +DECLOP_1VAR_ASSIGN(long1, /=) +DECLOP_1VAR_ASSIGN(long1, %=) +DECLOP_1VAR_ASSIGN(long1, &=) +DECLOP_1VAR_ASSIGN(long1, |=) +DECLOP_1VAR_ASSIGN(long1, ^=) +DECLOP_1VAR_ASSIGN(long1, <<=) +DECLOP_1VAR_ASSIGN(long1, >>=) + +DECLOP_1VAR_PREOP(long1, ++) +DECLOP_1VAR_PREOP(long1, --) + +DECLOP_1VAR_POSTOP(long1, ++) +DECLOP_1VAR_POSTOP(long1, --) + +DECLOP_1VAR_COMP(long1, ==) +DECLOP_1VAR_COMP(long1, !=) +DECLOP_1VAR_COMP(long1, <) +DECLOP_1VAR_COMP(long1, >) +DECLOP_1VAR_COMP(long1, <=) +DECLOP_1VAR_COMP(long1, >=) + +DECLOP_1VAR_COMP(long1, &&) +DECLOP_1VAR_COMP(long1, ||) + +DECLOP_1VAR_1IN_1OUT(long1, ~) +DECLOP_1VAR_1IN_BOOLOUT(long1, !) + +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(long1, float) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(long1, double) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed long long) + +// SIGNED LONG2 + +DECLOP_2VAR_2IN_1OUT(long2, +) +DECLOP_2VAR_2IN_1OUT(long2, -) +DECLOP_2VAR_2IN_1OUT(long2, *) +DECLOP_2VAR_2IN_1OUT(long2, /) +DECLOP_2VAR_2IN_1OUT(long2, %) +DECLOP_2VAR_2IN_1OUT(long2, &) +DECLOP_2VAR_2IN_1OUT(long2, |) +DECLOP_2VAR_2IN_1OUT(long2, ^) +DECLOP_2VAR_2IN_1OUT(long2, <<) +DECLOP_2VAR_2IN_1OUT(long2, >>) + +DECLOP_2VAR_ASSIGN(long2, +=) +DECLOP_2VAR_ASSIGN(long2, -=) +DECLOP_2VAR_ASSIGN(long2, *=) +DECLOP_2VAR_ASSIGN(long2, /=) +DECLOP_2VAR_ASSIGN(long2, %=) +DECLOP_2VAR_ASSIGN(long2, &=) +DECLOP_2VAR_ASSIGN(long2, |=) +DECLOP_2VAR_ASSIGN(long2, ^=) +DECLOP_2VAR_ASSIGN(long2, <<=) +DECLOP_2VAR_ASSIGN(long2, >>=) + +DECLOP_2VAR_PREOP(long2, ++) +DECLOP_2VAR_PREOP(long2, --) + +DECLOP_2VAR_POSTOP(long2, ++) +DECLOP_2VAR_POSTOP(long2, --) + +DECLOP_2VAR_COMP(long2, ==) +DECLOP_2VAR_COMP(long2, !=) +DECLOP_2VAR_COMP(long2, <) +DECLOP_2VAR_COMP(long2, >) +DECLOP_2VAR_COMP(long2, <=) +DECLOP_2VAR_COMP(long2, >=) + +DECLOP_2VAR_COMP(long2, &&) +DECLOP_2VAR_COMP(long2, ||) + +DECLOP_2VAR_1IN_1OUT(long2, ~) +DECLOP_2VAR_1IN_BOOLOUT(long2, !) + +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(long2, float) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(long2, double) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed long long) + +// SIGNED LONG3 + +DECLOP_3VAR_2IN_1OUT(long3, +) +DECLOP_3VAR_2IN_1OUT(long3, -) +DECLOP_3VAR_2IN_1OUT(long3, *) +DECLOP_3VAR_2IN_1OUT(long3, /) +DECLOP_3VAR_2IN_1OUT(long3, %) +DECLOP_3VAR_2IN_1OUT(long3, &) +DECLOP_3VAR_2IN_1OUT(long3, |) +DECLOP_3VAR_2IN_1OUT(long3, ^) +DECLOP_3VAR_2IN_1OUT(long3, <<) +DECLOP_3VAR_2IN_1OUT(long3, >>) + +DECLOP_3VAR_ASSIGN(long3, +=) +DECLOP_3VAR_ASSIGN(long3, -=) +DECLOP_3VAR_ASSIGN(long3, *=) +DECLOP_3VAR_ASSIGN(long3, /=) +DECLOP_3VAR_ASSIGN(long3, %=) +DECLOP_3VAR_ASSIGN(long3, &=) +DECLOP_3VAR_ASSIGN(long3, |=) +DECLOP_3VAR_ASSIGN(long3, ^=) +DECLOP_3VAR_ASSIGN(long3, <<=) +DECLOP_3VAR_ASSIGN(long3, >>=) + +DECLOP_3VAR_PREOP(long3, ++) +DECLOP_3VAR_PREOP(long3, --) + +DECLOP_3VAR_POSTOP(long3, ++) +DECLOP_3VAR_POSTOP(long3, --) + +DECLOP_3VAR_COMP(long3, ==) +DECLOP_3VAR_COMP(long3, !=) +DECLOP_3VAR_COMP(long3, <) +DECLOP_3VAR_COMP(long3, >) +DECLOP_3VAR_COMP(long3, <=) +DECLOP_3VAR_COMP(long3, >=) + +DECLOP_3VAR_COMP(long3, &&) +DECLOP_3VAR_COMP(long3, ||) + +DECLOP_3VAR_1IN_1OUT(long3, ~) +DECLOP_3VAR_1IN_BOOLOUT(long3, !) + +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(long3, float) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(long3, double) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed long long) + +// SIGNED LONG4 + +DECLOP_4VAR_2IN_1OUT(long4, +) +DECLOP_4VAR_2IN_1OUT(long4, -) +DECLOP_4VAR_2IN_1OUT(long4, *) +DECLOP_4VAR_2IN_1OUT(long4, /) +DECLOP_4VAR_2IN_1OUT(long4, %) +DECLOP_4VAR_2IN_1OUT(long4, &) +DECLOP_4VAR_2IN_1OUT(long4, |) +DECLOP_4VAR_2IN_1OUT(long4, ^) +DECLOP_4VAR_2IN_1OUT(long4, <<) +DECLOP_4VAR_2IN_1OUT(long4, >>) + +DECLOP_4VAR_ASSIGN(long4, +=) +DECLOP_4VAR_ASSIGN(long4, -=) +DECLOP_4VAR_ASSIGN(long4, *=) +DECLOP_4VAR_ASSIGN(long4, /=) +DECLOP_4VAR_ASSIGN(long4, %=) +DECLOP_4VAR_ASSIGN(long4, &=) +DECLOP_4VAR_ASSIGN(long4, |=) +DECLOP_4VAR_ASSIGN(long4, ^=) +DECLOP_4VAR_ASSIGN(long4, <<=) +DECLOP_4VAR_ASSIGN(long4, >>=) + +DECLOP_4VAR_PREOP(long4, ++) +DECLOP_4VAR_PREOP(long4, --) + +DECLOP_4VAR_POSTOP(long4, ++) +DECLOP_4VAR_POSTOP(long4, --) + +DECLOP_4VAR_COMP(long4, ==) +DECLOP_4VAR_COMP(long4, !=) +DECLOP_4VAR_COMP(long4, <) +DECLOP_4VAR_COMP(long4, >) +DECLOP_4VAR_COMP(long4, <=) +DECLOP_4VAR_COMP(long4, >=) + +DECLOP_4VAR_COMP(long4, &&) +DECLOP_4VAR_COMP(long4, ||) + +DECLOP_4VAR_1IN_1OUT(long4, ~) +DECLOP_4VAR_1IN_BOOLOUT(long4, !) + +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(long4, float) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(long4, double) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed long long) + +// UNSIGNED LONGLONG1 + +DECLOP_1VAR_2IN_1OUT(ulonglong1, +) +DECLOP_1VAR_2IN_1OUT(ulonglong1, -) +DECLOP_1VAR_2IN_1OUT(ulonglong1, *) +DECLOP_1VAR_2IN_1OUT(ulonglong1, /) +DECLOP_1VAR_2IN_1OUT(ulonglong1, %) +DECLOP_1VAR_2IN_1OUT(ulonglong1, &) +DECLOP_1VAR_2IN_1OUT(ulonglong1, |) +DECLOP_1VAR_2IN_1OUT(ulonglong1, ^) +DECLOP_1VAR_2IN_1OUT(ulonglong1, <<) +DECLOP_1VAR_2IN_1OUT(ulonglong1, >>) + + +DECLOP_1VAR_ASSIGN(ulonglong1, +=) +DECLOP_1VAR_ASSIGN(ulonglong1, -=) +DECLOP_1VAR_ASSIGN(ulonglong1, *=) +DECLOP_1VAR_ASSIGN(ulonglong1, /=) +DECLOP_1VAR_ASSIGN(ulonglong1, %=) +DECLOP_1VAR_ASSIGN(ulonglong1, &=) +DECLOP_1VAR_ASSIGN(ulonglong1, |=) +DECLOP_1VAR_ASSIGN(ulonglong1, ^=) +DECLOP_1VAR_ASSIGN(ulonglong1, <<=) +DECLOP_1VAR_ASSIGN(ulonglong1, >>=) + +DECLOP_1VAR_PREOP(ulonglong1, ++) +DECLOP_1VAR_PREOP(ulonglong1, --) + +DECLOP_1VAR_POSTOP(ulonglong1, ++) +DECLOP_1VAR_POSTOP(ulonglong1, --) + +DECLOP_1VAR_COMP(ulonglong1, ==) +DECLOP_1VAR_COMP(ulonglong1, !=) +DECLOP_1VAR_COMP(ulonglong1, <) +DECLOP_1VAR_COMP(ulonglong1, >) +DECLOP_1VAR_COMP(ulonglong1, <=) +DECLOP_1VAR_COMP(ulonglong1, >=) + +DECLOP_1VAR_COMP(ulonglong1, &&) +DECLOP_1VAR_COMP(ulonglong1, ||) + +DECLOP_1VAR_1IN_1OUT(ulonglong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ulonglong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, float) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, double) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed long long) + +// UNSIGNED LONGLONG2 + +DECLOP_2VAR_2IN_1OUT(ulonglong2, +) +DECLOP_2VAR_2IN_1OUT(ulonglong2, -) +DECLOP_2VAR_2IN_1OUT(ulonglong2, *) +DECLOP_2VAR_2IN_1OUT(ulonglong2, /) +DECLOP_2VAR_2IN_1OUT(ulonglong2, %) +DECLOP_2VAR_2IN_1OUT(ulonglong2, &) +DECLOP_2VAR_2IN_1OUT(ulonglong2, |) +DECLOP_2VAR_2IN_1OUT(ulonglong2, ^) +DECLOP_2VAR_2IN_1OUT(ulonglong2, <<) +DECLOP_2VAR_2IN_1OUT(ulonglong2, >>) + +DECLOP_2VAR_ASSIGN(ulonglong2, +=) +DECLOP_2VAR_ASSIGN(ulonglong2, -=) +DECLOP_2VAR_ASSIGN(ulonglong2, *=) +DECLOP_2VAR_ASSIGN(ulonglong2, /=) +DECLOP_2VAR_ASSIGN(ulonglong2, %=) +DECLOP_2VAR_ASSIGN(ulonglong2, &=) +DECLOP_2VAR_ASSIGN(ulonglong2, |=) +DECLOP_2VAR_ASSIGN(ulonglong2, ^=) +DECLOP_2VAR_ASSIGN(ulonglong2, <<=) +DECLOP_2VAR_ASSIGN(ulonglong2, >>=) + +DECLOP_2VAR_PREOP(ulonglong2, ++) +DECLOP_2VAR_PREOP(ulonglong2, --) + +DECLOP_2VAR_POSTOP(ulonglong2, ++) +DECLOP_2VAR_POSTOP(ulonglong2, --) + +DECLOP_2VAR_COMP(ulonglong2, ==) +DECLOP_2VAR_COMP(ulonglong2, !=) +DECLOP_2VAR_COMP(ulonglong2, <) +DECLOP_2VAR_COMP(ulonglong2, >) +DECLOP_2VAR_COMP(ulonglong2, <=) +DECLOP_2VAR_COMP(ulonglong2, >=) + +DECLOP_2VAR_COMP(ulonglong2, &&) +DECLOP_2VAR_COMP(ulonglong2, ||) + +DECLOP_2VAR_1IN_1OUT(ulonglong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ulonglong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, float) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, double) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed long long) + +// UNSIGNED LONGLONG3 + +DECLOP_3VAR_2IN_1OUT(ulonglong3, +) +DECLOP_3VAR_2IN_1OUT(ulonglong3, -) +DECLOP_3VAR_2IN_1OUT(ulonglong3, *) +DECLOP_3VAR_2IN_1OUT(ulonglong3, /) +DECLOP_3VAR_2IN_1OUT(ulonglong3, %) +DECLOP_3VAR_2IN_1OUT(ulonglong3, &) +DECLOP_3VAR_2IN_1OUT(ulonglong3, |) +DECLOP_3VAR_2IN_1OUT(ulonglong3, ^) +DECLOP_3VAR_2IN_1OUT(ulonglong3, <<) +DECLOP_3VAR_2IN_1OUT(ulonglong3, >>) + +DECLOP_3VAR_ASSIGN(ulonglong3, +=) +DECLOP_3VAR_ASSIGN(ulonglong3, -=) +DECLOP_3VAR_ASSIGN(ulonglong3, *=) +DECLOP_3VAR_ASSIGN(ulonglong3, /=) +DECLOP_3VAR_ASSIGN(ulonglong3, %=) +DECLOP_3VAR_ASSIGN(ulonglong3, &=) +DECLOP_3VAR_ASSIGN(ulonglong3, |=) +DECLOP_3VAR_ASSIGN(ulonglong3, ^=) +DECLOP_3VAR_ASSIGN(ulonglong3, <<=) +DECLOP_3VAR_ASSIGN(ulonglong3, >>=) + +DECLOP_3VAR_PREOP(ulonglong3, ++) +DECLOP_3VAR_PREOP(ulonglong3, --) + +DECLOP_3VAR_POSTOP(ulonglong3, ++) +DECLOP_3VAR_POSTOP(ulonglong3, --) + +DECLOP_3VAR_COMP(ulonglong3, ==) +DECLOP_3VAR_COMP(ulonglong3, !=) +DECLOP_3VAR_COMP(ulonglong3, <) +DECLOP_3VAR_COMP(ulonglong3, >) +DECLOP_3VAR_COMP(ulonglong3, <=) +DECLOP_3VAR_COMP(ulonglong3, >=) + +DECLOP_3VAR_COMP(ulonglong3, &&) +DECLOP_3VAR_COMP(ulonglong3, ||) + +DECLOP_3VAR_1IN_1OUT(ulonglong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ulonglong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, float) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, double) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed long long) + +// UNSIGNED LONGLONG4 + +DECLOP_4VAR_2IN_1OUT(ulonglong4, +) +DECLOP_4VAR_2IN_1OUT(ulonglong4, -) +DECLOP_4VAR_2IN_1OUT(ulonglong4, *) +DECLOP_4VAR_2IN_1OUT(ulonglong4, /) +DECLOP_4VAR_2IN_1OUT(ulonglong4, %) +DECLOP_4VAR_2IN_1OUT(ulonglong4, &) +DECLOP_4VAR_2IN_1OUT(ulonglong4, |) +DECLOP_4VAR_2IN_1OUT(ulonglong4, ^) +DECLOP_4VAR_2IN_1OUT(ulonglong4, <<) +DECLOP_4VAR_2IN_1OUT(ulonglong4, >>) + +DECLOP_4VAR_ASSIGN(ulonglong4, +=) +DECLOP_4VAR_ASSIGN(ulonglong4, -=) +DECLOP_4VAR_ASSIGN(ulonglong4, *=) +DECLOP_4VAR_ASSIGN(ulonglong4, /=) +DECLOP_4VAR_ASSIGN(ulonglong4, %=) +DECLOP_4VAR_ASSIGN(ulonglong4, &=) +DECLOP_4VAR_ASSIGN(ulonglong4, |=) +DECLOP_4VAR_ASSIGN(ulonglong4, ^=) +DECLOP_4VAR_ASSIGN(ulonglong4, <<=) +DECLOP_4VAR_ASSIGN(ulonglong4, >>=) + +DECLOP_4VAR_PREOP(ulonglong4, ++) +DECLOP_4VAR_PREOP(ulonglong4, --) + +DECLOP_4VAR_POSTOP(ulonglong4, ++) +DECLOP_4VAR_POSTOP(ulonglong4, --) + +DECLOP_4VAR_COMP(ulonglong4, ==) +DECLOP_4VAR_COMP(ulonglong4, !=) +DECLOP_4VAR_COMP(ulonglong4, <) +DECLOP_4VAR_COMP(ulonglong4, >) +DECLOP_4VAR_COMP(ulonglong4, <=) +DECLOP_4VAR_COMP(ulonglong4, >=) + +DECLOP_4VAR_COMP(ulonglong4, &&) +DECLOP_4VAR_COMP(ulonglong4, ||) + +DECLOP_4VAR_1IN_1OUT(ulonglong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ulonglong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, float) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, double) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed long long) + +// SIGNED LONGLONG1 + +DECLOP_1VAR_2IN_1OUT(longlong1, +) +DECLOP_1VAR_2IN_1OUT(longlong1, -) +DECLOP_1VAR_2IN_1OUT(longlong1, *) +DECLOP_1VAR_2IN_1OUT(longlong1, /) +DECLOP_1VAR_2IN_1OUT(longlong1, %) +DECLOP_1VAR_2IN_1OUT(longlong1, &) +DECLOP_1VAR_2IN_1OUT(longlong1, |) +DECLOP_1VAR_2IN_1OUT(longlong1, ^) +DECLOP_1VAR_2IN_1OUT(longlong1, <<) +DECLOP_1VAR_2IN_1OUT(longlong1, >>) + + +DECLOP_1VAR_ASSIGN(longlong1, +=) +DECLOP_1VAR_ASSIGN(longlong1, -=) +DECLOP_1VAR_ASSIGN(longlong1, *=) +DECLOP_1VAR_ASSIGN(longlong1, /=) +DECLOP_1VAR_ASSIGN(longlong1, %=) +DECLOP_1VAR_ASSIGN(longlong1, &=) +DECLOP_1VAR_ASSIGN(longlong1, |=) +DECLOP_1VAR_ASSIGN(longlong1, ^=) +DECLOP_1VAR_ASSIGN(longlong1, <<=) +DECLOP_1VAR_ASSIGN(longlong1, >>=) + +DECLOP_1VAR_PREOP(longlong1, ++) +DECLOP_1VAR_PREOP(longlong1, --) + +DECLOP_1VAR_POSTOP(longlong1, ++) +DECLOP_1VAR_POSTOP(longlong1, --) + +DECLOP_1VAR_COMP(longlong1, ==) +DECLOP_1VAR_COMP(longlong1, !=) +DECLOP_1VAR_COMP(longlong1, <) +DECLOP_1VAR_COMP(longlong1, >) +DECLOP_1VAR_COMP(longlong1, <=) +DECLOP_1VAR_COMP(longlong1, >=) + +DECLOP_1VAR_COMP(longlong1, &&) +DECLOP_1VAR_COMP(longlong1, ||) + +DECLOP_1VAR_1IN_1OUT(longlong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(longlong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, float) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, double) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed long long) + +// SIGNED LONGLONG2 + +DECLOP_2VAR_2IN_1OUT(longlong2, +) +DECLOP_2VAR_2IN_1OUT(longlong2, -) +DECLOP_2VAR_2IN_1OUT(longlong2, *) +DECLOP_2VAR_2IN_1OUT(longlong2, /) +DECLOP_2VAR_2IN_1OUT(longlong2, %) +DECLOP_2VAR_2IN_1OUT(longlong2, &) +DECLOP_2VAR_2IN_1OUT(longlong2, |) +DECLOP_2VAR_2IN_1OUT(longlong2, ^) +DECLOP_2VAR_2IN_1OUT(longlong2, <<) +DECLOP_2VAR_2IN_1OUT(longlong2, >>) + +DECLOP_2VAR_ASSIGN(longlong2, +=) +DECLOP_2VAR_ASSIGN(longlong2, -=) +DECLOP_2VAR_ASSIGN(longlong2, *=) +DECLOP_2VAR_ASSIGN(longlong2, /=) +DECLOP_2VAR_ASSIGN(longlong2, %=) +DECLOP_2VAR_ASSIGN(longlong2, &=) +DECLOP_2VAR_ASSIGN(longlong2, |=) +DECLOP_2VAR_ASSIGN(longlong2, ^=) +DECLOP_2VAR_ASSIGN(longlong2, <<=) +DECLOP_2VAR_ASSIGN(longlong2, >>=) + +DECLOP_2VAR_PREOP(longlong2, ++) +DECLOP_2VAR_PREOP(longlong2, --) + +DECLOP_2VAR_POSTOP(longlong2, ++) +DECLOP_2VAR_POSTOP(longlong2, --) + +DECLOP_2VAR_COMP(longlong2, ==) +DECLOP_2VAR_COMP(longlong2, !=) +DECLOP_2VAR_COMP(longlong2, <) +DECLOP_2VAR_COMP(longlong2, >) +DECLOP_2VAR_COMP(longlong2, <=) +DECLOP_2VAR_COMP(longlong2, >=) + +DECLOP_2VAR_COMP(longlong2, &&) +DECLOP_2VAR_COMP(longlong2, ||) + +DECLOP_2VAR_1IN_1OUT(longlong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(longlong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, float) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, double) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed long long) + +// SIGNED LONGLONG3 + +DECLOP_3VAR_2IN_1OUT(longlong3, +) +DECLOP_3VAR_2IN_1OUT(longlong3, -) +DECLOP_3VAR_2IN_1OUT(longlong3, *) +DECLOP_3VAR_2IN_1OUT(longlong3, /) +DECLOP_3VAR_2IN_1OUT(longlong3, %) +DECLOP_3VAR_2IN_1OUT(longlong3, &) +DECLOP_3VAR_2IN_1OUT(longlong3, |) +DECLOP_3VAR_2IN_1OUT(longlong3, ^) +DECLOP_3VAR_2IN_1OUT(longlong3, <<) +DECLOP_3VAR_2IN_1OUT(longlong3, >>) + +DECLOP_3VAR_ASSIGN(longlong3, +=) +DECLOP_3VAR_ASSIGN(longlong3, -=) +DECLOP_3VAR_ASSIGN(longlong3, *=) +DECLOP_3VAR_ASSIGN(longlong3, /=) +DECLOP_3VAR_ASSIGN(longlong3, %=) +DECLOP_3VAR_ASSIGN(longlong3, &=) +DECLOP_3VAR_ASSIGN(longlong3, |=) +DECLOP_3VAR_ASSIGN(longlong3, ^=) +DECLOP_3VAR_ASSIGN(longlong3, <<=) +DECLOP_3VAR_ASSIGN(longlong3, >>=) + +DECLOP_3VAR_PREOP(longlong3, ++) +DECLOP_3VAR_PREOP(longlong3, --) + +DECLOP_3VAR_POSTOP(longlong3, ++) +DECLOP_3VAR_POSTOP(longlong3, --) + +DECLOP_3VAR_COMP(longlong3, ==) +DECLOP_3VAR_COMP(longlong3, !=) +DECLOP_3VAR_COMP(longlong3, <) +DECLOP_3VAR_COMP(longlong3, >) +DECLOP_3VAR_COMP(longlong3, <=) +DECLOP_3VAR_COMP(longlong3, >=) + +DECLOP_3VAR_COMP(longlong3, &&) +DECLOP_3VAR_COMP(longlong3, ||) + +DECLOP_3VAR_1IN_1OUT(longlong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(longlong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, float) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, double) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed long long) + +// SIGNED LONGLONG4 + +DECLOP_4VAR_2IN_1OUT(longlong4, +) +DECLOP_4VAR_2IN_1OUT(longlong4, -) +DECLOP_4VAR_2IN_1OUT(longlong4, *) +DECLOP_4VAR_2IN_1OUT(longlong4, /) +DECLOP_4VAR_2IN_1OUT(longlong4, %) +DECLOP_4VAR_2IN_1OUT(longlong4, &) +DECLOP_4VAR_2IN_1OUT(longlong4, |) +DECLOP_4VAR_2IN_1OUT(longlong4, ^) +DECLOP_4VAR_2IN_1OUT(longlong4, <<) +DECLOP_4VAR_2IN_1OUT(longlong4, >>) + +DECLOP_4VAR_ASSIGN(longlong4, +=) +DECLOP_4VAR_ASSIGN(longlong4, -=) +DECLOP_4VAR_ASSIGN(longlong4, *=) +DECLOP_4VAR_ASSIGN(longlong4, /=) +DECLOP_4VAR_ASSIGN(longlong4, %=) +DECLOP_4VAR_ASSIGN(longlong4, &=) +DECLOP_4VAR_ASSIGN(longlong4, |=) +DECLOP_4VAR_ASSIGN(longlong4, ^=) +DECLOP_4VAR_ASSIGN(longlong4, <<=) +DECLOP_4VAR_ASSIGN(longlong4, >>=) + +DECLOP_4VAR_PREOP(longlong4, ++) +DECLOP_4VAR_PREOP(longlong4, --) + +DECLOP_4VAR_POSTOP(longlong4, ++) +DECLOP_4VAR_POSTOP(longlong4, --) + +DECLOP_4VAR_COMP(longlong4, ==) +DECLOP_4VAR_COMP(longlong4, !=) +DECLOP_4VAR_COMP(longlong4, <) +DECLOP_4VAR_COMP(longlong4, >) +DECLOP_4VAR_COMP(longlong4, <=) +DECLOP_4VAR_COMP(longlong4, >=) + +DECLOP_4VAR_COMP(longlong4, &&) +DECLOP_4VAR_COMP(longlong4, ||) + +DECLOP_4VAR_1IN_1OUT(longlong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(longlong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, float) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, double) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed long long) + + #endif +#endif diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 906c39421e..5864cfa0e7 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,15 @@ THE SOFTWARE. * @brief TODO-doc */ -#ifndef HOST_DEFINES_H -#define HOST_DEFINES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H + +#define USE_PROMOTE_FREE_HCC 1 + +// Add guard to Generic Grid Launch method +#ifndef GENERIC_GRID_LAUNCH +#define GENERIC_GRID_LAUNCH 1 +#endif #ifdef __HCC__ /** @@ -35,7 +42,14 @@ THE SOFTWARE. #define __host__ __attribute__((cpu)) #define __device__ __attribute__((hc)) -#define __global__ __attribute__((hc_grid_launch)) +//#warning "HOST DEFINE header included" +#if GENERIC_GRID_LAUNCH == 0 +//#warning "original global define reached" +#define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) +#else +//#warning "GGL global define reached" +#define __global__ __attribute__((hc, weak)) +#endif //GENERIC_GRID_LAUNCH #define __noinline__ __attribute__((noinline)) #define __forceinline__ __attribute__((always_inline)) @@ -47,7 +61,11 @@ THE SOFTWARE. */ // _restrict is supported by the compiler #define __shared__ tile_static -#define __constant__ __attribute__((address_space(1))) +#if USE_PROMOTE_FREE_HCC==1 +#define __constant__ __attribute__((hc)) +#else +#define __constant__ ADDRESS_SPACE_1 +#endif #else // Non-HCC compiler diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h new file mode 100644 index 0000000000..9faff2743a --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -0,0 +1,267 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H + +#include +#include +#include + +__device__ float acosf(float x); +__device__ float acoshf(float x); +__device__ float asinf(float x); +__device__ float asinhf(float x); +__device__ float atan2f(float y, float x); +__device__ float atanf(float x); +__device__ float atanhf(float x); +__device__ float cbrtf(float x); +__device__ float ceilf(float x); +__device__ float copysignf(float x, float y); +__device__ float cosf(float x); +__device__ float coshf(float x); +__device__ float cospif(float x); +//__device__ float cyl_bessel_i0f(float x); +//__device__ float cyl_bessel_i1f(float x); +__device__ float erfcf(float x); +__device__ float erfcinvf(float y); +__device__ float erfcxf(float x); +__device__ float erff(float x); +__device__ float erfinvf(float y); +__device__ float exp10f(float x); +__device__ float exp2f(float x); +__device__ float expf(float x); +__device__ float expm1f(float x); +__device__ int abs(int x); +__device__ float fabsf(float x); +__device__ float fdimf(float x, float y); +__device__ float fdividef(float x, float y); +__device__ float floorf(float x); +__device__ float fmaf(float x, float y, float z); +__device__ float fmaxf(float x, float y); +__device__ float fminf(float x, float y); +__device__ float fmodf(float x, float y); +//__device__ float frexpf(float x, int* nptr); +__device__ float hypotf(float x, float y); +__device__ float ilogbf(float x); +__device__ int isfinite(float a); +__device__ unsigned isinf(float a); +__device__ unsigned isnan(float a); +__device__ float j0f(float x); +__device__ float j1f(float x); +__device__ float jnf(int n, float x); +__device__ float ldexpf(float x, int exp); +__device__ float lgammaf(float x); +__device__ long long int llrintf(float x); +__device__ long long int llroundf(float x); +__device__ float log10f(float x); +__device__ float log1pf(float x); +__device__ float logbf(float x); +__device__ long int lrintf(float x); +__device__ long int lroundf(float x); +//__device__ float modff(float x, float *iptr); +__device__ float nanf(const char* tagp); +__device__ float nearbyintf(float x); +//__device__ float nextafterf(float x, float y); +__device__ float norm3df(float a, float b, float c); +__device__ float norm4df(float a, float b, float c, float d); +__device__ float normcdff(float y); +__device__ float normcdfinvf(float y); +__device__ float normf(int dim, const float *a); +__device__ float powf(float x, float y); +__device__ float rcbrtf(float x); +__device__ float remainderf(float x, float y); +__device__ float remquof(float x, float y, int *quo); +__device__ float rhypotf(float x, float y); +__device__ float rintf(float x); +__device__ float rnorm3df(float a, float b, float c); +__device__ float rnorm4df(float a, float b, float c, float d); +__device__ float rnormf(int dim, const float* a); +__device__ float roundf(float x); +__device__ float rsqrtf(float x); +__device__ float scalblnf(float x, long int n); +__device__ float scalbnf(float x, int n); +__device__ int signbit(float a); +__device__ void sincosf(float x, float *sptr, float *cptr); +__device__ void sincospif(float x, float *sptr, float *cptr); +__device__ float sinf(float x); +__device__ float sinhf(float x); +__device__ float sinpif(float x); +__device__ float sqrtf(float x); +__device__ float tanf(float x); +__device__ float tanhf(float x); +__device__ float tgammaf(float x); +__device__ float truncf(float x); +__device__ float y0f(float x); +__device__ float y1f(float x); +__device__ float ynf(int n, float x); + +__device__ double acos(double x); +__device__ double acosh(double x); +__device__ double asin(double x); +__device__ double asinh(double x); +__device__ double atan(double x); +__device__ double atan2(double y, double x); +__device__ double atanh(double x); +__device__ double cbrt(double x); +__device__ double ceil(double x); +__device__ double copysign(double x, double y); +__device__ double cos(double x); +__device__ double cosh(double x); +__device__ double cospi(double x); +//__device__ double cyl_bessel_i0(double x); +//__device__ double cyl_bessel_i1(double x); +__device__ double erf(double x); +__device__ double erfc(double x); +__device__ double erfcinv(double y); +__device__ double erfcx(double x); +__device__ double erfinv(double x); +__device__ double exp(double x); +__device__ double exp10(double x); +__device__ double exp2(double x); +__device__ double expm1(double x); +__device__ double fabs(double x); +__device__ double fdim(double x, double y); +__device__ double floor(double x); +__device__ double fma(double x, double y, double z); +__device__ double fmax(double x, double y); +__device__ double fmin(double x, double y); +__device__ double fmod(double x, double y); +//__device__ double frexp(double x, int *nptr); +__device__ double hypot(double x, double y); +__device__ double ilogb(double x); +__device__ int isfinite(double x); +__device__ unsigned isinf(double x); +__device__ unsigned isnan(double x); +__device__ double j0(double x); +__device__ double j1(double x); +__device__ double jn(int n, double x); +__device__ double ldexp(double x, int exp); +__device__ double lgamma(double x); +__device__ long long llrint(double x); +__device__ long long llround(double x); +__device__ double log(double x); +__device__ double log10(double x); +__device__ double log1p(double x); +__device__ double log2(double x); +__device__ double logb(double x); +__device__ long int lrint(double x); +__device__ long int lround(double x); +//__device__ double modf(double x, double *iptr); +__device__ double nan(const char* tagp); +__device__ double nearbyint(double x); +__device__ double nextafter(double x, double y); +__device__ double norm(int dim, const double* t); +__device__ double norm3d(double a, double b, double c); +__device__ double norm4d(double a, double b, double c, double d); +__device__ double normcdf(double y); +__device__ double normcdfinv(double y); +__device__ double pow(double x, double y); +__device__ double rcbrt(double x); +__device__ double remainder(double x, double y); +//__device__ double remquo(double x, double y, int *quo); +__device__ double rhypot(double x, double y); +__device__ double rint(double x); +__device__ double rnorm(int dim, const double* t); +__device__ double rnorm3d(double a, double b, double c); +__device__ double rnorm4d(double a, double b, double c, double d); +__device__ double round(double x); +__device__ double rsqrt(double x); +__device__ double scalbln(double x, long int n); +__device__ double scalbn(double x, int n); +__device__ int signbit(double a); +__device__ double sin(double a); +__device__ void sincos(double x, double *sptr, double *cptr); +__device__ void sincospi(double x, double *sptr, double *cptr); +__device__ double sinh(double x); +__device__ double sinpi(double x); +__device__ double sqrt(double x); +__device__ double tan(double x); +__device__ double tanh(double x); +__device__ double tgamma(double x); +__device__ double trunc(double x); +__device__ double y0(double x); +__device__ double y1(double y); +__device__ double yn(int n, double x); + +// ENDPARSER + +#ifdef HIP_FAST_MATH +// Single Precision Precise Math when enabled + +__device__ inline float cosf(float x) { + return __hip_fast_cosf(x); +} + +__device__ inline float exp10f(float x) { + return __hip_fast_exp10f(x); +} + +__device__ inline float expf(float x) { + return __hip_fast_expf(x); +} + +__device__ inline float log10f(float x) { + return __hip_fast_log10f(x); +} + +__device__ inline float log2f(float x) { + return __hip_fast_log2f(x); +} + +__device__ inline float logf(float x) { + return __hip_fast_logf(x); +} + +__device__ inline float powf(float base, float exponent) { + return __hip_fast_powf(base, exponent); +} + +__device__ inline void sincosf(float x, float *s, float *c) { + return __hip_fast_sincosf(x, s, c); +} + +__device__ inline float sinf(float x) { + return __hip_fast_sinf(x); +} + +__device__ inline float tanf(float x) { + return __hip_fast_tanf(x); +} + +#else + +__device__ float sinf(float); +__device__ float cosf(float); +__device__ float tanf(float); +__device__ void sincosf(float, float*, float*); +__device__ float logf(float); +__device__ float log2f(float); +__device__ float log10f(float); +__device__ float expf(float); +__device__ float exp10f(float); +__device__ float powf(float, float); + +#endif + + +#endif diff --git a/projects/hip/include/hip/hcc_detail/texture_types.h b/projects/hip/include/hip/hcc_detail/texture_types.h new file mode 100644 index 0000000000..74680bbc76 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -0,0 +1,45 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H + +#include + +enum hipTextureReadMode +{ + hipReadModeElementType = 0 +}; + +enum hipTextureFilterMode +{ + hipFilterModePoint = 0 +}; + +struct textureReference { + enum hipTextureFilterMode filterMode; + unsigned normalized; + struct hipChannelFormatDesc channelDesc; +}; + +#endif diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index 4c75568f4d..da8ec4a55d 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,40 +20,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_COMMON_H +#define HIP_INCLUDE_HIP_HIP_COMMON_H // Common code included at start of every hip file. // Auto enable __HIP_PLATFORM_HCC__ if compiling with HCC // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly -#if defined(__HCC__) +#if defined(__HCC__) #define __HIP_PLATFORM_HCC__ -#define __HIPCC__ - -#if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 -#endif -#endif +#endif //__HCC__ // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC -#if defined(__NVCC__) +#if defined(__NVCC__) #define __HIP_PLATFORM_NVCC__ -# ifdef __CUDACC__ -# define __HIPCC__ -# endif - -#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 +#ifdef __CUDACC__ +#define __HIPCC__ #endif +#endif //__NVCC__ + +// Auto enable __HIP_DEVICE_COMPILE__ if compiled in HCC or NVCC device path +#if (defined(__HCC_ACCELERATOR__) && __HCC_ACCELERATOR__ != 0) || (defined(__CUDA_ARCH__) && __CUDA_ARCH__ != 0) + #define __HIP_DEVICE_COMPILE__ 1 #endif - - - #if __HIP_DEVICE_COMPILE__ == 0 // 32-bit Atomics #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (0) @@ -84,3 +74,5 @@ THE SOFTWARE. #define __HIP_ARCH_HAS_3DGRID__ (0) #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0) #endif + +#endif diff --git a/projects/hip/include/hip/hip_complex.h b/projects/hip/include/hip/hip_complex.h index 0f4fb0b3d8..dc691be480 100644 --- a/projects/hip/include/hip/hip_complex.h +++ b/projects/hip/include/hip/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_HIP_COMPLEX_H #include @@ -32,3 +33,4 @@ THE SOFTWARE. #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif +#endif diff --git a/projects/hip/include/hip/hip_fp16.h b/projects/hip/include/hip/hip_fp16.h index b91063998a..95879dba50 100644 --- a/projects/hip/include/hip/hip_fp16.h +++ b/projects/hip/include/hip/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_FP16_H +#define HIP_INCLUDE_HIP_HIP_FP16_H #include @@ -31,3 +32,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/hip_hcc.h b/projects/hip/include/hip/hip_hcc.h new file mode 100644 index 0000000000..3407a311bd --- /dev/null +++ b/projects/hip/include/hip/hip_hcc.h @@ -0,0 +1,30 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HIP_HCC_H +#define HIP_INCLUDE_HIP_HIP_HCC_H + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include "hip/hcc_detail/hip_hcc.h" +#endif + +#endif diff --git a/projects/hip/include/hip/hip_profile.h b/projects/hip/include/hip/hip_profile.h index 489143adfd..389f334c74 100644 --- a/projects/hip/include/hip/hip_profile.h +++ b/projects/hip/include/hip/hip_profile.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_PROFILE_H +#define HIP_INCLUDE_HIP_HIP_PROFILE_H #if not defined (ENABLE_HIP_PROFILE) #define ENABLE_HIP_PROFILE 1 @@ -32,7 +33,9 @@ THE SOFTWARE. #define HIP_BEGIN_MARKER(markerName, group) amdtBeginMarker(markerName, group, nullptr); #define HIP_END_MARKER() amdtEndMarker(); #else -#define HIP_SCOPED_MARKER(markerName, group) +#define HIP_SCOPED_MARKER(markerName, group) #define HIP_BEGIN_MARKER(markerName, group) -#define HIP_END_MARKER() +#define HIP_END_MARKER() +#endif + #endif diff --git a/projects/hip/include/hip/hip_runtime.h b/projects/hip/include/hip/hip_runtime.h index dff1e19252..fba4d46d8f 100644 --- a/projects/hip/include/hip/hip_runtime.h +++ b/projects/hip/include/hip/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ THE SOFTWARE. //! HIP = Heterogeneous-compute Interface for Portability //! -//! Define a extremely thin runtime layer that allows source code to be compiled unmodified +//! Define a extremely thin runtime layer that allows source code to be compiled unmodified //! through either AMD HCC or NVCC. Key features tend to be in the spirit //! and terminology of CUDA, but with a portable path to other accelerators as well: // @@ -33,7 +33,8 @@ THE SOFTWARE. //! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. //! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_HIP_RUNTIME_H // Some standard header files, these are included by hc.hpp and so want to make them avail on both // paths to provide a consistent include env and avoid "missing symbol" errors that only appears @@ -54,11 +55,12 @@ THE SOFTWARE. #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif #include #include +#endif diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index a45a1ee27e..8eae1d6a3a 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,8 @@ THE SOFTWARE. * This file can be compiled with a standard compiler. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_HIP_RUNTIME_API_H #include // for getDeviceProp @@ -106,6 +107,7 @@ typedef struct hipDeviceProp_t { size_t maxSharedMemoryPerMultiProcessor; ///< Maximum Shared Memory Per Multiprocessor. int isMultiGpuBoard; ///< 1 if device is on a multi-GPU board, 0 if not. int canMapHostMemory; ///< Check whether HIP can map host memory + int gcnArch; ///< AMD GCN Arch Value. Eg: 803, 701 } hipDeviceProp_t; @@ -181,6 +183,7 @@ typedef enum hipError_t { hipErrorSharedObjectSymbolNotFound = 302, hipErrorSharedObjectInitFailed = 303, hipErrorOperatingSystem = 304, + hipErrorSetOnActiveProcess = 305, hipErrorInvalidHandle = 400, hipErrorNotFound = 500, hipErrorIllegalAddress = 700, @@ -281,3 +284,5 @@ static inline hipError_t hipHostMalloc( T** ptr, size_t size, unsigned int flags return hipHostMalloc((void**)ptr, size, flags); } #endif + +#endif diff --git a/projects/hip/include/hip/hip_texture.h b/projects/hip/include/hip/hip_texture.h index 3e7802b457..a15c5a1016 100644 --- a/projects/hip/include/hip/hip_texture.h +++ b/projects/hip/include/hip/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,18 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - -#ifndef HIP_HIP_TEXTURE_H -#define HIP_HIP_TEXTURE_H +#ifndef HIP_INCLUDE_HIP_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_HIP_TEXTURE_H #if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif #endif diff --git a/projects/hip/include/hip/hip_vector_types.h b/projects/hip/include/hip/hip_vector_types.h index 7733d92bda..1d3d6b92f6 100644 --- a/projects/hip/include/hip/hip_vector_types.h +++ b/projects/hip/include/hip/hip_vector_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,8 @@ THE SOFTWARE. //! hip_vector_types.h : Defines the HIP vector types. -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_VECTOR_TYPES_H +#define HIP_INCLUDE_HIP_HIP_VECTOR_TYPES_H #include @@ -33,6 +34,8 @@ THE SOFTWARE. #endif #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif + +#endif diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h new file mode 100644 index 0000000000..6f47b5e0e2 --- /dev/null +++ b/projects/hip/include/hip/math_functions.h @@ -0,0 +1,39 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_MATH_FUNCTIONS_H +#define HIP_INCLUDE_HIP_MATH_FUNCTIONS_H + +// Some standard header files, these are included by hc.hpp and so want to make them avail on both +// paths to provide a consistent include env and avoid "missing symbol" errors that only appears +// on NVCC path: + + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +//#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/channel_descriptor.h b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h new file mode 100644 index 0000000000..2e88c56268 --- /dev/null +++ b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h @@ -0,0 +1,28 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H + +#include"channel_descriptor.h" + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/hip_complex.h b/projects/hip/include/hip/nvcc_detail/hip_complex.h index 174cabc12c..20cb24460c 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_complex.h +++ b/projects/hip/include/hip/nvcc_detail/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIPCOMPLEX_H -#define HIPCOMPLEX_H +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H #include"cuComplex.h" @@ -64,7 +64,7 @@ __device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hi } __device__ __host__ static inline float hipCabsf(hipFloatComplex z){ - return cuCabsf(p, q); + return cuCabsf(z); } typedef cuDoubleComplex hipDoubleComplex; @@ -85,7 +85,7 @@ __device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ return cuConj(z); } -__device__ __host__ static inline hipDoubleComplex hipCsqabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCsqabs(hipDoubleComplex z){ return cuCabs(z) * cuCabs(z); } @@ -123,7 +123,7 @@ __device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q return cuCfmaf(p, q, r); } -__device__ __host__ static inline hipDoubleComplex hipCfma(hipComplex p, hipComplex q, hipComplex r){ +__device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ return cuCfma(p, q, r); } diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime.h b/projects/hip/include/hip/nvcc_detail/hip_runtime.h index 2c774bfb7d..80da388007 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H #include @@ -35,6 +36,10 @@ do {\ kernelName<<>>(0, ##__VA_ARGS__);\ } while(0) +#define hipLaunchKernelGGL(kernelName, numblocks, numthreads, memperblock, streamId, ...) \ +do {\ +kernelName<<>>(__VA_ARGS__);\ +} while(0) #define hipReadModeElementType cudaReadModeElementType @@ -105,3 +110,5 @@ kernelName<<>>(0, ##__VA_ARGS__);\ #define HIP_DYNAMIC_SHARED_ATTRIBUTE #endif + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 5f5931cf1b..0cc40f32af 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H #include #include @@ -85,6 +86,10 @@ typedef CUdevice hipDevice_t; typedef CUmodule hipModule_t; typedef CUfunction hipFunction_t; typedef CUdeviceptr hipDeviceptr_t; +typedef cudaChannelFormatKind hipChannelFormatKind; +typedef cudaChannelFormatDesc hipChannelFormatDesc; +typedef cudaTextureReadMode hipTextureReadMode; +typedef cudaArray hipArray; // Flags that can be used with hipStreamCreateWithFlags #define hipStreamDefault cudaStreamDefault @@ -215,6 +220,14 @@ inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int fla return hipCUDAErrorTohipError(cudaHostAlloc(ptr, size, flags)); } +inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { + return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); +} + +inline static hipError_t hipFreeArray(hipArray* array) { + return hipCUDAErrorTohipError(cudaFreeArray(array)); +} + inline static hipError_t hipHostGetDevicePointer(void** devPtr, void* hostPtr, unsigned int flags){ return hipCUDAErrorTohipError(cudaHostGetDevicePointer(devPtr, hostPtr, flags)); } @@ -294,13 +307,13 @@ inline static hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, inline static hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t size, hipStream_t stream) { - return hipCUResultTohipError(cuMemcpyDtoH(dst, src, size)); + return hipCUResultTohipError(cuMemcpyDtoHAsync(dst, src, size, stream)); } inline static hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t size, hipStream_t stream) { - return hipCUResultTohipError(cuMemcpyDtoD(dst, src, size)); + return hipCUResultTohipError(cuMemcpyDtoDAsync(dst, src, size, stream)); } inline static hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind copyKind) { @@ -321,6 +334,28 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* return hipCUDAErrorTohipError(cudaMemcpyToSymbolAsync(symbol, src, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(copyType))); } +inline static hipError_t hipMemcpyFromSymbol(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind) +{ + return hipCUDAErrorTohipError(cudaMemcpyFromSymbol(dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind))); +} + +inline static hipError_t hipMemcpyFromSymbolAsync(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) +{ + return hipCUDAErrorTohipError(cudaMemcpyFromSymbolAsync(dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind), stream)); +} + +inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ + return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); +} + +inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); +} + +inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { + return hipCUDAErrorTohipError(cudaMemcpyToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); +} + inline static hipError_t hipDeviceSynchronize() { return hipCUDAErrorTohipError(cudaDeviceSynchronize()); } @@ -373,6 +408,11 @@ inline static hipError_t hipMemsetAsync(void* devPtr,int value, size_t count, hi return hipCUDAErrorTohipError(cudaMemsetAsync(devPtr, value, count, stream)); } +inline static hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes ) +{ + return hipCUResultTohipError(cuMemsetD8(dest, value, sizeBytes)); +} + inline static hipError_t hipGetDeviceProperties(hipDeviceProp_t *p_prop, int device) { cudaDeviceProp cdprop; @@ -478,6 +518,8 @@ inline static hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t att cdattr = cudaDevAttrMaxThreadsPerMultiProcessor; break; case hipDeviceAttributeComputeCapabilityMajor: cdattr = cudaDevAttrComputeCapabilityMajor; break; + case hipDeviceAttributeComputeCapabilityMinor: + cdattr = cudaDevAttrComputeCapabilityMinor; break; case hipDeviceAttributeConcurrentKernels: cdattr = cudaDevAttrConcurrentKernels; break; case hipDeviceAttributePciBusId: @@ -639,6 +681,31 @@ inline static hipError_t hipCtxEnablePeerAccess ( hipCtx_t peerCtx, unsigned in return hipCUResultTohipError(cuCtxEnablePeerAccess(peerCtx, flags)); } +inline static hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxGetState(dev, flags, active)); +} + +inline static hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxRelease(dev)); +} + +inline static hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxRetain(pctx, dev)); +} + +inline static hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxReset(dev)); +} + +inline static hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxSetFlags(dev, flags)); +} + inline static hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr ) { return hipCUResultTohipError(cuMemGetAddressRange( pbase , psize , dptr)); @@ -770,11 +837,6 @@ inline static hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) return hipCUResultTohipError(cuDeviceGetName(name,len,device)); } -inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,int device) -{ - return hipCUDAErrorTohipError(cudaDeviceGetPCIBusId(pciBusId,len,device)); -} - inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,hipDevice_t device) { return hipCUResultTohipError(cuDeviceGetPCIBusId(pciBusId,len,device)); @@ -886,4 +948,6 @@ inline static hipChannelFormatDesc hipCreateChannelDesc() { return cudaCreateChannelDesc(); } -#endif +#endif //__CUDACC__ + +#endif //HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H diff --git a/projects/hip/include/hip/nvcc_detail/hip_texture.h b/projects/hip/include/hip/nvcc_detail/hip_texture.h index 388733e492..c669d62192 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_texture.h +++ b/projects/hip/include/hip/nvcc_detail/hip_texture.h @@ -1,5 +1,27 @@ -#ifndef HIP_TEXTURE_H -#define HIP_TEXTURE_H +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H #include diff --git a/projects/hip/include/hip/texture_types.h b/projects/hip/include/hip/texture_types.h new file mode 100644 index 0000000000..ca6101cf79 --- /dev/null +++ b/projects/hip/include/hip/texture_types.h @@ -0,0 +1,36 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_TEXTURE_TYPES_H + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include "texture_types.h" +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/packaging/create_hip_samples_installer.sh b/projects/hip/packaging/create_hip_samples_installer.sh deleted file mode 100755 index 91789d2524..0000000000 --- a/projects/hip/packaging/create_hip_samples_installer.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -function die { - echo "${1-Died}." >&2 - exit 1 -} - -payload=$1 -script=$2 -[ "$payload" != "" ] || [ "$script" != "" ] || die "Invalid arguments!" -tmp=__extract__$RANDOM - -printf "#!/bin/bash -samples_dir=\$1 -[ \"\$samples_dir\" != \"\" ] || read -e -p \"Enter the path to extract the HIP samples: \" samples_dir -mkdir -p \$samples_dir -PAYLOAD=\`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' \$0\` -tail -n+\$PAYLOAD \$0 | tar -xz -C \$samples_dir -echo \"HIP samples installed in \$samples_dir\" -exit 0 -__PAYLOAD_BELOW__\n" > "$tmp" - -cat "$tmp" "$payload" > "$script" && rm "$tmp" -chmod +x "$script" diff --git a/projects/hip/packaging/hip-targets-release.cmake b/projects/hip/packaging/hip-targets-release.cmake new file mode 100644 index 0000000000..ba0a5005f5 --- /dev/null +++ b/projects/hip/packaging/hip-targets-release.cmake @@ -0,0 +1,41 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "hip::hip_hcc_static" for configuration "Release" +set_property(TARGET hip::hip_hcc_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_hcc_static PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hc_am" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc_static.a" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc_static ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc_static "/opt/rocm/hip/lib/libhip_hcc_static.a" ) + +# Import target "hip::hip_hcc" for configuration "Release" +set_property(TARGET hip::hip_hcc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_hcc PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hcc::hccrt;hcc::hc_am" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc.so" + IMPORTED_SONAME_RELEASE "libhip_hcc.so" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc "/opt/rocm/hip/lib/libhip_hcc.so" ) + +# Import target "hip::hip_device" for configuration "Release" +set_property(TARGET hip::hip_device APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_device PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_device.a" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_device ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_device "/opt/rocm/hip/lib/libhip_device.a" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/projects/hip/packaging/hip-targets.cmake b/projects/hip/packaging/hip-targets.cmake new file mode 100644 index 0000000000..65370eec9e --- /dev/null +++ b/projects/hip/packaging/hip-targets.cmake @@ -0,0 +1,102 @@ +# Generated by CMake 3.5.1 + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget hip::hip_hcc_static hip::hip_hcc hip::hip_device) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# The installation prefix configured by this project. +set(_IMPORT_PREFIX "/opt/rocm/hip") + +# Create imported target hip::hip_hcc_static +add_library(hip::hip_hcc_static STATIC IMPORTED) + +set_target_properties(hip::hip_hcc_static PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Create imported target hip::hip_hcc +add_library(hip::hip_hcc SHARED IMPORTED) + +set_target_properties(hip::hip_hcc PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Create imported target hip::hip_device +add_library(hip::hip_device STATIC IMPORTED) + +set_target_properties(hip::hip_device PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/hip-targets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/projects/hip/packaging/hip_base.txt b/projects/hip/packaging/hip_base.txt index a208bc3463..836a82657b 100644 --- a/projects/hip/packaging/hip_base.txt +++ b/projects/hip/packaging/hip_base.txt @@ -33,5 +33,6 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_doc.txt b/projects/hip/packaging/hip_doc.txt index bbcaf54ec8..6f602c84cf 100644 --- a/projects/hip/packaging/hip_doc.txt +++ b/projects/hip/packaging/hip_doc.txt @@ -1,12 +1,19 @@ cmake_minimum_required(VERSION 2.8.3) project(hip_doc) -add_custom_target(build_doxygen ALL +find_program(DOXYGEN_EXE doxygen) +if(DOXYGEN_EXE) + add_custom_target(build_doxygen ALL COMMAND HIP_PATH=@hip_SOURCE_DIR@ doxygen @hip_SOURCE_DIR@/docs/doxygen-input/doxy.cfg) -add_custom_target(convert_md_to_html ALL + install(DIRECTORY RuntimeAPI/html DESTINATION docs/docs/RuntimeAPI) +endif() + +find_program(GRIP_EXE grip) +if(GRIP_EXE) + add_custom_target(convert_md_to_html ALL COMMAND @hip_SOURCE_DIR@/packaging/convert_md_to_html.sh @hip_SOURCE_DIR@ ${PROJECT_BINARY_DIR}/md2html) -install(DIRECTORY RuntimeAPI/html DESTINATION docs/docs/RuntimeAPI) -install(DIRECTORY md2html/ DESTINATION docs) + install(DIRECTORY md2html/ DESTINATION docs) +endif() ############################# # Packaging steps @@ -29,5 +36,6 @@ set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_hcc.postinst b/projects/hip/packaging/hip_hcc.postinst index 14179db767..c7f9c3184c 100755 --- a/projects/hip/packaging/hip_hcc.postinst +++ b/projects/hip/packaging/hip_hcc.postinst @@ -8,17 +8,22 @@ popd () { } ROCMDIR=/opt/rocm -HIPDIR=$ROCMDIR/hip - -# Soft-link to libraries -HIPLIBFILES=$HIPDIR/lib/* ROCMLIBDIR=$ROCMDIR/lib +HIPDIR=$ROCMDIR/hip +HIPLIBDIR=$ROCMDIR/hip/lib + +# Soft-link to library files +HIPLIBFILES=$(ls -aF $HIPLIBDIR | grep -v [-/$]) mkdir -p $ROCMLIBDIR +mkdir -p $ROCMLIBDIR/cmake pushd $ROCMLIBDIR for f in $HIPLIBFILES do - ln -s $f $(basename $f) + ln -s $HIPLIBDIR/$f $(basename $f) done - ln -s $HIPDIR/lib/.hipInfo .hipInfo +# Make the hip cmake directory link. +pushd cmake +ln -s $HIPLIBDIR/cmake/hip hip +popd popd diff --git a/projects/hip/packaging/hip_hcc.prerm b/projects/hip/packaging/hip_hcc.prerm index dda313a3a4..ee64aea632 100755 --- a/projects/hip/packaging/hip_hcc.prerm +++ b/projects/hip/packaging/hip_hcc.prerm @@ -9,17 +9,21 @@ popd () { } ROCMDIR=/opt/rocm +ROCMLIBDIR=$ROCMDIR/lib HIPDIR=$ROCMDIR/hip +HIPLIBDIR=$ROCMDIR/hip/lib # Remove soft-links to libraries -HIPLIBFILES=$HIPDIR/lib/* -ROCMLIBDIR=$ROCMDIR/lib +HIPLIBFILES=$(ls -aF $HIPLIBDIR | grep -v [-/$]) pushd $ROCMLIBDIR for f in $HIPLIBFILES do rm $(basename $f) done -rm .hipInfo +pushd cmake +unlink hip +popd +rmdir --ignore-fail-on-non-empty cmake popd rmdir --ignore-fail-on-non-empty $ROCMLIBDIR diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 00a62ab14c..b0808aa0bc 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -5,7 +5,9 @@ install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/libhip_hcc_static.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/libhip_device.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib) -install(FILES @hip_SOURCE_DIR@/src/hip_ir.ll DESTINATION lib) +install(FILES @hip_SOURCE_DIR@/src/hip_hc.ll @hip_SOURCE_DIR@/src/hip_hc_gfx803.ll DESTINATION lib) +install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip) +install(FILES @hip_SOURCE_DIR@/packaging/hip-targets.cmake @hip_SOURCE_DIR@/packaging/hip-targets-release.cmake DESTINATION lib/cmake/hip) ############################# # Packaging steps @@ -13,6 +15,11 @@ install(FILES @hip_SOURCE_DIR@/src/hip_ir.ll DESTINATION lib) set(CPACK_SET_DESTDIR TRUE) set(CPACK_INSTALL_PREFIX "/opt/rocm/hip") set(CPACK_PACKAGE_NAME "hip_hcc") +if(@HCC_VERSION_MAJOR@ EQUAL 0) + set(HCC_PACKAGE_NAME "hcc_lc") +else() + set(HCC_PACKAGE_NAME "hcc") +endif() set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HCC]") set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") set(CPACK_PACKAGE_CONTACT "Maneesh Gupta ") @@ -25,9 +32,9 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") if(@COMPILE_HIP_ATP_MARKER@) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), hcc_lc (= @HCC_PACKAGE_VERSION@), rocm-profiler") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), rocm-profiler") else() - set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), hcc_lc (= @HCC_PACKAGE_VERSION@)") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@)") endif() set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") @@ -35,9 +42,10 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") if(@COMPILE_HIP_ATP_MARKER@) - set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, hcc_lc = @HCC_PACKAGE_VERSION@, rocm-profiler") + set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, rocm-profiler") else() - set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, hcc_lc = @HCC_PACKAGE_VERSION@") + set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@") endif() +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_nvcc.txt b/projects/hip/packaging/hip_nvcc.txt index ea4943f282..0d7c357623 100644 --- a/projects/hip/packaging/hip_nvcc.txt +++ b/projects/hip/packaging/hip_nvcc.txt @@ -25,5 +25,6 @@ set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") #set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, cuda >= 7.5") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_samples.txt b/projects/hip/packaging/hip_samples.txt index f289f2a8e5..6d34a6fd40 100644 --- a/projects/hip/packaging/hip_samples.txt +++ b/projects/hip/packaging/hip_samples.txt @@ -24,5 +24,6 @@ set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/samples/0_Intro/bit_extract/Makefile b/projects/hip/samples/0_Intro/bit_extract/Makefile index 0965ae7296..08bca6e642 100644 --- a/projects/hip/samples/0_Intro/bit_extract/Makefile +++ b/projects/hip/samples/0_Intro/bit_extract/Makefile @@ -11,10 +11,6 @@ HIPCC=$(HIP_PATH)/bin/hipcc ifeq (${HIP_PLATFORM}, nvcc) HIPCC_FLAGS = -gencode=arch=compute_20,code=sm_20 endif -ifeq (${HIP_PLATFORM}, hcc) - HIPCC_FLAGS = -stdlib=libc++ -endif - EXE=bit_extract @@ -24,4 +20,3 @@ $(EXE): bit_extract.cpp clean: rm -f *.o $(EXE) - diff --git a/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp b/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp index 1535d2bd98..a30f2d052d 100644 --- a/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp +++ b/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. }\ } -void __global__ +__global__ void bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t N) { size_t offset = (hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x); @@ -45,7 +45,7 @@ bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t for (size_t i=offset; i> 8); #endif @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) C_h = (uint32_t*)malloc(Nbytes); CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); - for (size_t i=0; i +#include +#include + +#define LEN 64 +#define SIZE LEN<<2 + +#define fileName "test.co" +#define kernel_name "vadd" + +int main(){ + float *A, *B, *C; + hipDeviceptr_t Ad, Bd, Cd; + A = new float[LEN]; + B = new float[LEN]; + C = new float[LEN]; + + for(uint32_t i=0;i +#include +#include + +#ifdef __HIP_PLATFORM_HCC__ +#include +#endif + +#define LEN 64 +#define SIZE LEN<<2 + +#define fileName "vcpy_kernel.code" +#define kernel_name "hello_world" + +#define HIP_CHECK(status) \ +if(status != hipSuccess) {std::cout<<"Got Status: "< -#include -#include +#include +#include +#include +#include #define LEN 64 #define SIZE LEN<<2 @@ -32,6 +33,9 @@ THE SOFTWARE. #define fileName "vcpy_kernel.code" #define kernel_name "hello_world" +#define HIP_CHECK(status) \ +if(status != hipSuccess) {std::cout<<"Got Status: "< @@ -58,16 +58,18 @@ int main(int argc, char *argv[]) hipDeviceProp_t props; CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/)); printf ("info: running on device %s\n", props.name); - + #ifdef __HIP_PLATFORM_HCC__ + printf ("info: architecture on AMD GPU device is: %d\n",props.gcnArch); + #endif printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); A_h = (float*)malloc(Nbytes); CHECK(A_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); C_h = (float*)malloc(Nbytes); CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); // Fill with Phi + i - for (size_t i=0; i #include #include -#include #endif #include @@ -23,7 +22,7 @@ bool g_printedTiming = false; // Cmdline parms: int p_device = 0; -const char* p_command = "H2D; NullKernel; D2H"; +const char* p_command = "setstream(1); H2D; NullKernel; D2H;"; const char* p_file = nullptr; unsigned p_verbose = 0x0; unsigned p_db = 0x0; diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm new file mode 100644 index 0000000000..640bb2be79 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm new file mode 100644 index 0000000000..c1bc0f6702 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..0e787f9bd0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..8d7fddc146 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm new file mode 100644 index 0000000000..7d845d03a4 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm new file mode 100644 index 0000000000..49c0d77146 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..fe1f14bee5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm new file mode 100644 index 0000000000..0762001daa --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm new file mode 100644 index 0000000000..88003ba476 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm new file mode 100644 index 0000000000..01913f8481 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..530eb8f68e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..6d83ee87c9 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm new file mode 100644 index 0000000000..8b9e233a9e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); streamsync; streamsync; endloop(1); +loop(10); streamsync; streamsync; endloop(1); +loop(100); streamsync; streamsync; endloop(1); +loop(100); streamsync; streamsync; endloop(1); +loop(1000); streamsync; streamsync; endloop(1); +loop(1000); streamsync; streamsync; endloop(1); +loop(10000); streamsync; streamsync; endloop(1); +loop(10000); streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm new file mode 100644 index 0000000000..83cdc4ff75 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H;streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm new file mode 100644 index 0000000000..4b91403582 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); D2H; D2H; streamsync; endloop(1); +loop(10); D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm new file mode 100644 index 0000000000..a2e4311bf6 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10); H2D; streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm new file mode 100644 index 0000000000..0c622614cc --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm new file mode 100644 index 0000000000..d73467da10 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D ; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm new file mode 100644 index 0000000000..35f5e68522 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; H2D; streamsync; endloop(1); +loop(10); H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm new file mode 100644 index 0000000000..3b85c6bef8 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm new file mode 100644 index 0000000000..584d6b8021 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm new file mode 100644 index 0000000000..7f0fce96c5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm new file mode 100644 index 0000000000..a384439b5c --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..1cab6ff0d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..ff5b09a3dc --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm new file mode 100644 index 0000000000..d8921a64e7 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); + diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm new file mode 100644 index 0000000000..4ccbf9a83c --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..a3d9a282f5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm new file mode 100644 index 0000000000..56554d15fd --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm new file mode 100644 index 0000000000..a6e3a683d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm new file mode 100644 index 0000000000..eae3eadc5b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..9e21709b0b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..b1ef7ef9f4 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm new file mode 100644 index 0000000000..bc8d21c594 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);streamsync; streamsync; streamsync; endloop(1); +loop(10);streamsync; streamsync; streamsync; endloop(1); +loop(100);streamsync; streamsync; streamsync; endloop(1); +loop(100);streamsync; streamsync; streamsync; endloop(1); +loop(1000);streamsync; streamsync; streamsync; endloop(1); +loop(1000);streamsync; streamsync; streamsync; endloop(1); +loop(10000);streamsync; streamsync; streamsync; endloop(1); +loop(10000);streamsync; streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm new file mode 100644 index 0000000000..4e07574b99 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H;streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm new file mode 100644 index 0000000000..e96707fed9 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; D2H; D2H; streamsync; endloop(1); +loop(10); D2H; D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; D2H;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm new file mode 100644 index 0000000000..82151adb8b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync;H2D;streamsync; H2D; streamsync; endloop(1); +loop(10); H2D; streamsync;H2D;streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync;H2D; streamsync;H2D; streamsync; endloop(1); +loop(100); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D;streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(10000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(10000); H2D;streamsync; H2D;streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm new file mode 100644 index 0000000000..7d96bfcfab --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; H2D; H2D; streamsync; endloop(1); +loop(10); H2D; H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm new file mode 100644 index 0000000000..2e8306dfde --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm new file mode 100644 index 0000000000..85cd0dd4d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm new file mode 100644 index 0000000000..48a8223626 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm new file mode 100644 index 0000000000..70ad00c248 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel;NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm new file mode 100644 index 0000000000..1bbb5694b1 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel;NullKernel;NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm new file mode 100644 index 0000000000..54f06a3481 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm new file mode 100644 index 0000000000..6667ba95fa --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm new file mode 100644 index 0000000000..fe770c5e9d --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..20ec951509 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..77e483b3df --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync;NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm new file mode 100644 index 0000000000..f5642bfdf0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync; endloop(1); +loop(10); H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm new file mode 100644 index 0000000000..05452b9c87 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm @@ -0,0 +1,2 @@ +setstream(1); +loop(10); H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm new file mode 100644 index 0000000000..dad9fc7437 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm new file mode 100644 index 0000000000..1b60640b9e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm new file mode 100644 index 0000000000..6e4e9f3544 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm new file mode 100644 index 0000000000..4e94a26ebf --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; NullKernel; D2H; streamsync;endloop(1); +loop(10); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm new file mode 100644 index 0000000000..b3b40d3190 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D ; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..030213d1b3 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm new file mode 100644 index 0000000000..146c74bcae --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..366d04f469 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; streamsync; NullKernel;streamsync; D2H; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm new file mode 100644 index 0000000000..027d89aad0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm new file mode 100644 index 0000000000..fb6a867e7f --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; streamsync; endloop(1); +loop(10); NullKernel; streamsync; streamsync; endloop(1); +loop(100); NullKernel; streamsync; streamsync; endloop(1); +loop(100); NullKernel; streamsync; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm new file mode 100644 index 0000000000..2e64472dbd --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync; endloop(1); +loop(10); NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm new file mode 100644 index 0000000000..b220a69c68 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync; endloop(1); +loop(10); NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..48b332b1c3 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..5a45d55376 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm new file mode 100644 index 0000000000..1e6aef5dc1 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm @@ -0,0 +1,2 @@ +setstream(1); +loop(10);setstream(1);setstream(2);setstream(3);setstream(4);setstream(5);streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm new file mode 100644 index 0000000000..a784013b1a --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); streamsync; endloop(1); +loop(10); streamsync; endloop(1); +loop(100); streamsync; endloop(1); +loop(100); streamsync; endloop(1); +loop(1000); streamsync; endloop(1); +loop(1000); streamsync; endloop(1); +loop(10000); streamsync; endloop(1); +loop(10000); streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp index 42a879e732..cf4660eae7 100644 --- a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp +++ b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp @@ -63,6 +63,14 @@ double bytesToGB(size_t s) return (double)s / (1024.0*1024.0*1024.0); } +#define printLimit(w1, limit, units) \ +{\ + size_t val;\ + cudaDeviceGetLimit(&val, limit);\ + std::cout << setw(w1) << #limit": " << val << " " << units << std::endl;\ +} + + void printDeviceProp (int deviceId) { using namespace std; @@ -144,6 +152,17 @@ void printDeviceProp (int deviceId) cout << endl; +#ifdef __HIP_PLATFORM_NVCC__ + // Limits: + cout << endl; + printLimit(w1, cudaLimitStackSize, "bytes/thread"); + printLimit(w1, cudaLimitPrintfFifoSize, "bytes/device"); + printLimit(w1, cudaLimitMallocHeapSize, "bytes/device"); + printLimit(w1, cudaLimitDevRuntimeSyncDepth, "grids"); + printLimit(w1, cudaLimitDevRuntimePendingLaunchCount, "launches"); +#endif + + cout << endl; diff --git a/projects/hip/samples/2_Cookbook/4_shfl/Makefile b/projects/hip/samples/2_Cookbook/4_shfl/Makefile index 3383cf2bf5..56f54d9518 100644 --- a/projects/hip/samples/2_Cookbook/4_shfl/Makefile +++ b/projects/hip/samples/2_Cookbook/4_shfl/Makefile @@ -3,6 +3,10 @@ ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif +ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) + $(error gfx701 is not a supported device for this sample) +endif + HIPCC=$(HIP_PATH)/bin/hipcc TARGET=hcc @@ -22,7 +26,7 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ + $(HIPCC) $(OBJECTS) -o $@ test: $(EXECUTABLE) @@ -33,4 +37,3 @@ clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) rm -f $(HIP_PATH)/src/*.o - diff --git a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile index b742bbf80a..cfadb1a311 100644 --- a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile +++ b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile @@ -3,6 +3,10 @@ ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif +ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) + $(error gfx701 is not a supported device for this sample) +endif + HIPCC=$(HIP_PATH)/bin/hipcc TARGET=hcc diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile b/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile deleted file mode 100644 index 8586e75d25..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc - -HIPCC_FLAGS += -std=c++11 -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --platform) -ifeq (${HIP_PLATFORM}, nvcc) - LIBS = -lcublas -endif -ifeq (${HIP_PLATFORM}, hcc) - HCBLAS_ROOT?= $(wildcard /opt/rocm/hcblas) - HIPCC_FLAGS += -stdlib=libc++ -I$(HCBLAS_ROOT)/include - LIBS = -L$(HCBLAS_ROOT)/lib -lhipblas -rpath $(HIP_PATH)/lib -endif - - -all: saxpy.hipblas.out - -saxpy.cublas.out : saxpy.cublas.cpp - nvcc -std=c++11 -I$(CUDA_HOME)/include saxpy.cublas.cpp -o $@ -L$(CUDA_HOME)/lib64 -lcublas - -# $HIPBLAS_ROOT/bin/hipifyblas ./saxpy.cublas.cpp > ./saxpy.hipblas.cpp -# Then review & finish port in saxpy.hipblas.cpp - -saxpy.hipblasref.o: saxpy.hipblasref.cpp - $(HIPCC) $(HIPCC_FLAGS) -c $< -o $@ - -saxpy.hipblas.out: saxpy.hipblasref.o - $(HIPCC) $< -o $@ $(LIBS) - -clean: - rm -f *.o *.out diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp b/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp deleted file mode 100644 index 03a38f3fb1..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -#include -#include -#include -#include - -// header file for the GPU API -#include -#include - -#define N (1024 * 500) - -#define CHECK(cmd) \ -{\ - cudaError_t error = cmd; \ - if (error != cudaSuccess) { \ - fprintf(stderr, "error: '%s'(%d) at %s:%d\n", cudaGetErrorString(error), error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -#define CHECK_BLAS(cmd) \ -{\ - cublasStatus_t error = cmd;\ - if (error != CUBLAS_STATUS_SUCCESS) { \ - fprintf(stderr, "error: (%d) at %s:%d\n", error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -int main() { - - const float a = 100.0f; - float x[N]; - float y[N], y_cpu_res[N], y_gpu_res[N]; - - // initialize the input data - std::default_random_engine random_gen; - std::uniform_real_distribution distribution(-N, N); - std::generate_n(x, N, [&]() { return distribution(random_gen); }); - std::generate_n(y, N, [&]() { return distribution(random_gen); }); - std::copy_n(y, N, y_cpu_res); - - // Explicit GPU code: - - size_t Nbytes = N*sizeof(float); - float *x_gpu, *y_gpu; - - cublasHandle_t handle; - - cudaDeviceProp props; - CHECK(cudaGetDeviceProperties(&props, 0/*deviceID*/)); - printf ("info: running on device %s\n", props.name); - - printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - printf ("info: allocate device mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - CHECK(cudaMalloc(&x_gpu, Nbytes)); - CHECK(cudaMalloc(&y_gpu, Nbytes)); - - // Initialize the blas library - CHECK_BLAS ( cublasCreate(&handle)); - - // copy n elements from a vector in host memory space to a vector in GPU memory space - printf ("info: copy Host2Device\n"); - CHECK_BLAS ( cublasSetVector(N, sizeof(*x), x, 1, x_gpu, 1)); - CHECK_BLAS ( cublasSetVector(N, sizeof(*y), y, 1, y_gpu, 1)); - - printf ("info: launch 'saxpy' kernel\n"); - CHECK_BLAS ( cublasSaxpy(handle, N, &a, x_gpu, 1, y_gpu, 1)); - - cudaDeviceSynchronize(); - - printf ("info: copy Device2Host\n"); - CHECK_BLAS ( cublasGetVector(N, sizeof(*y_gpu_res), y_gpu, 1, y_gpu_res, 1)); - - // CPU implementation of saxpy - for (int i = 0; i < N; i++) { - y_cpu_res[i] = a * x[i] + y[i]; - } - - // verify the results - int errors = 0; - for (int i = 0; i < N; i++) { - if (fabs(y_cpu_res[i] - y_gpu_res[i]) > fabs(y_cpu_res[i] * 0.0001f)) - errors++; - } - std::cout << errors << " errors" << std::endl; - - CHECK( cudaFree(x_gpu)); - CHECK( cudaFree(y_gpu)); - CHECK_BLAS( cublasDestroy(handle)); - - return errors; -} diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp b/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp deleted file mode 100644 index 4610a612d4..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -#include -#include -#include -#include - -// header file for the GPU API -#include "hip/hip_runtime.h" -#include - -#define N (1024 * 500) - -#define CHECK(cmd) \ -{\ - hipError_t error = cmd; \ - if (error != hipSuccess) { \ - fprintf(stderr, "error: '%s'(%d) at %s:%d\n", hipGetErrorString(error), error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -#define CHECK_BLAS(cmd) \ -{\ - hipblasStatus_t error = cmd;\ - if (error != HIPBLAS_STATUS_SUCCESS) { \ - fprintf(stderr, "error: (%d) at %s:%d\n", error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -int main() { - - const float a = 100.0f; - float x[N]; - float y[N], y_cpu_res[N], y_gpu_res[N]; - - // initialize the input data - std::default_random_engine random_gen; - std::uniform_real_distribution distribution(-N, N); - std::generate_n(x, N, [&]() { return distribution(random_gen); }); - std::generate_n(y, N, [&]() { return distribution(random_gen); }); - std::copy_n(y, N, y_cpu_res); - - // Explicit GPU code: - - size_t Nbytes = N*sizeof(float); - float *x_gpu, *y_gpu; - - hipblasHandle_t handle; - - hipDeviceProp_t props; - CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/)); - printf ("info: running on device %s\n", props.name); - - printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - printf ("info: allocate device mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - CHECK(hipMalloc(&x_gpu, Nbytes)); - CHECK(hipMalloc(&y_gpu, Nbytes)); - - // Initialize the blas library - CHECK_BLAS ( hipblasCreate(&handle)); - - // copy n elements from a vector in host memory space to a vector in GPU memory space - printf ("info: copy Host2Device\n"); - CHECK_BLAS ( hipblasSetVector(N, sizeof(*x), x, 1, x_gpu, 1)); - CHECK_BLAS ( hipblasSetVector(N, sizeof(*y), y, 1, y_gpu, 1)); - - printf ("info: launch 'saxpy' kernel\n"); - CHECK_BLAS ( hipblasSaxpy(handle, N, &a, x_gpu, 1, y_gpu, 1)); - - hipDeviceSynchronize(); - - printf ("info: copy Device2Host\n"); - CHECK_BLAS ( hipblasGetVector(N, sizeof(*y_gpu_res), y_gpu, 1, y_gpu_res, 1)); - - // CPU implementation of saxpy - for (int i = 0; i < N; i++) { - y_cpu_res[i] = a * x[i] + y[i]; - } - - // verify the results - int errors = 0; - for (int i = 0; i < N; i++) { - if (fabs(y_cpu_res[i] - y_gpu_res[i]) > fabs(y_cpu_res[i] * 0.0001f)) - errors++; - } - std::cout << errors << " errors" << std::endl; - - CHECK( hipFree(x_gpu)); - CHECK( hipFree(y_gpu)); - CHECK_BLAS( hipblasDestroy(handle)); - - return errors; -} diff --git a/projects/hip/src/AMDGPUPTNote.h b/projects/hip/src/AMDGPUPTNote.h new file mode 100644 index 0000000000..8f8c855a52 --- /dev/null +++ b/projects/hip/src/AMDGPUPTNote.h @@ -0,0 +1,45 @@ +//===-- AMDGPUNoteType.h - AMDGPU ELF PT_NOTE section info-------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +/// \file +/// +/// Enums and constants for AMDGPU PT_NOTE sections. +/// +// +//===----------------------------------------------------------------------===// +// +#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUPTNOTE_H +#define LLVM_LIB_TARGET_AMDGPU_AMDGPUPTNOTE_H + +namespace AMDGPU { + +namespace ElfNote { + +const char SectionName[] = ".note"; + +const char NoteName[] = "AMD"; + +// TODO: Move this enum to include/llvm/Support so it can be used in tools? +enum NoteType{ + NT_AMDGPU_HSA_CODE_OBJECT_VERSION = 1, + NT_AMDGPU_HSA_HSAIL = 2, + NT_AMDGPU_HSA_ISA = 3, + NT_AMDGPU_HSA_PRODUCER = 4, + NT_AMDGPU_HSA_PRODUCER_OPTIONS = 5, + NT_AMDGPU_HSA_EXTENSION = 6, + NT_AMDGPU_HSA_RUNTIME_METADATA_V_1 = 7, // deprecated since 12/14/16. + NT_AMDGPU_HSA_RUNTIME_METADATA_V_2 = 8, + NT_AMDGPU_HSA_RUNTIME_METADATA = NT_AMDGPU_HSA_RUNTIME_METADATA_V_2, + NT_AMDGPU_HSA_HLDEBUG_DEBUG = 101, + NT_AMDGPU_HSA_HLDEBUG_TARGET = 102 +}; +} +} + +#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUNOTETYPE_H diff --git a/projects/hip/src/AMDGPURuntimeMetadata.h b/projects/hip/src/AMDGPURuntimeMetadata.h new file mode 100644 index 0000000000..ed147ff4c4 --- /dev/null +++ b/projects/hip/src/AMDGPURuntimeMetadata.h @@ -0,0 +1,290 @@ +//===-- AMDGPURuntimeMetadata.h - AMDGPU Runtime Metadata -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +/// \file +/// +/// Enums and structure types used by runtime metadata. +/// +/// Runtime requests certain information (metadata) about kernels to be able +/// to execute the kernels and answer the queries about the kernels. +/// The metadata is represented as a note element in the .note ELF section of a +/// binary (code object). The desc field of the note element is a YAML string +/// consisting of key-value pairs. Each key is a string. Each value can be +/// an integer, a string, or an YAML sequence. There are 3 levels of YAML maps. +/// At the beginning of the YAML string is the module level YAML map. A +/// kernel-level YAML map is in the amd.Kernels sequence. A +/// kernel-argument-level map is in the amd.Args sequence. +/// +/// The format should be kept backward compatible. New enum values and bit +/// fields should be appended at the end. It is suggested to bump up the +/// revision number whenever the format changes and document the change +/// in the revision in this header. +/// +// +//===----------------------------------------------------------------------===// +// +#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H +#define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H + +#include +#include +#include + +namespace AMDGPU { +namespace RuntimeMD { + + // Version and revision of runtime metadata + const unsigned char MDVersion = 2; + const unsigned char MDRevision = 1; + + // Name of keys for runtime metadata. + namespace KeyName { + + // Runtime metadata version + const char MDVersion[] = "amd.MDVersion"; + + // Instruction set architecture information + const char IsaInfo[] = "amd.IsaInfo"; + // Wavefront size + const char IsaInfoWavefrontSize[] = "amd.IsaInfoWavefrontSize"; + // Local memory size in bytes + const char IsaInfoLocalMemorySize[] = "amd.IsaInfoLocalMemorySize"; + // Number of execution units per compute unit + const char IsaInfoEUsPerCU[] = "amd.IsaInfoEUsPerCU"; + // Maximum number of waves per execution unit + const char IsaInfoMaxWavesPerEU[] = "amd.IsaInfoMaxWavesPerEU"; + // Maximum flat work group size + const char IsaInfoMaxFlatWorkGroupSize[] = "amd.IsaInfoMaxFlatWorkGroupSize"; + // SGPR allocation granularity + const char IsaInfoSGPRAllocGranule[] = "amd.IsaInfoSGPRAllocGranule"; + // Total number of SGPRs + const char IsaInfoTotalNumSGPRs[] = "amd.IsaInfoTotalNumSGPRs"; + // Addressable number of SGPRs + const char IsaInfoAddressableNumSGPRs[] = "amd.IsaInfoAddressableNumSGPRs"; + // VGPR allocation granularity + const char IsaInfoVGPRAllocGranule[] = "amd.IsaInfoVGPRAllocGranule"; + // Total number of VGPRs + const char IsaInfoTotalNumVGPRs[] = "amd.IsaInfoTotalNumVGPRs"; + // Addressable number of VGPRs + const char IsaInfoAddressableNumVGPRs[] = "amd.IsaInfoAddressableNumVGPRs"; + + // Language + const char Language[] = "amd.Language"; + // Language version + const char LanguageVersion[] = "amd.LanguageVersion"; + + // Kernels + const char Kernels[] = "amd.Kernels"; + // Kernel name + const char KernelName[] = "amd.KernelName"; + // Kernel arguments + const char Args[] = "amd.Args"; + // Kernel argument size in bytes + const char ArgSize[] = "amd.ArgSize"; + // Kernel argument alignment + const char ArgAlign[] = "amd.ArgAlign"; + // Kernel argument type name + const char ArgTypeName[] = "amd.ArgTypeName"; + // Kernel argument name + const char ArgName[] = "amd.ArgName"; + // Kernel argument kind + const char ArgKind[] = "amd.ArgKind"; + // Kernel argument value type + const char ArgValueType[] = "amd.ArgValueType"; + // Kernel argument address qualifier + const char ArgAddrQual[] = "amd.ArgAddrQual"; + // Kernel argument access qualifier + const char ArgAccQual[] = "amd.ArgAccQual"; + // Kernel argument is const qualified + const char ArgIsConst[] = "amd.ArgIsConst"; + // Kernel argument is restrict qualified + const char ArgIsRestrict[] = "amd.ArgIsRestrict"; + // Kernel argument is volatile qualified + const char ArgIsVolatile[] = "amd.ArgIsVolatile"; + // Kernel argument is pipe qualified + const char ArgIsPipe[] = "amd.ArgIsPipe"; + // Required work group size + const char ReqdWorkGroupSize[] = "amd.ReqdWorkGroupSize"; + // Work group size hint + const char WorkGroupSizeHint[] = "amd.WorkGroupSizeHint"; + // Vector type hint + const char VecTypeHint[] = "amd.VecTypeHint"; + // Kernel index for device enqueue + const char KernelIndex[] = "amd.KernelIndex"; + // No partial work groups + const char NoPartialWorkGroups[] = "amd.NoPartialWorkGroups"; + // Prinf function call information + const char PrintfInfo[] = "amd.PrintfInfo"; + // The actual kernel argument access qualifier + const char ArgActualAcc[] = "amd.ArgActualAcc"; + // Alignment of pointee type + const char ArgPointeeAlign[] = "amd.ArgPointeeAlign"; + + } // end namespace KeyName + + namespace KernelArg { + + enum Kind : uint8_t { + ByValue = 0, + GlobalBuffer = 1, + DynamicSharedPointer = 2, + Sampler = 3, + Image = 4, + Pipe = 5, + Queue = 6, + HiddenGlobalOffsetX = 7, + HiddenGlobalOffsetY = 8, + HiddenGlobalOffsetZ = 9, + HiddenNone = 10, + HiddenPrintfBuffer = 11, + HiddenDefaultQueue = 12, + HiddenCompletionAction = 13, + }; + + enum ValueType : uint16_t { + Struct = 0, + I8 = 1, + U8 = 2, + I16 = 3, + U16 = 4, + F16 = 5, + I32 = 6, + U32 = 7, + F32 = 8, + I64 = 9, + U64 = 10, + F64 = 11, + }; + + // Avoid using 'None' since it conflicts with a macro in X11 header file. + enum AccessQualifer : uint8_t { + AccNone = 0, + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = 3, + }; + + enum AddressSpaceQualifer : uint8_t { + Private = 0, + Global = 1, + Constant = 2, + Local = 3, + Generic = 4, + Region = 5, + }; + + } // end namespace KernelArg + + // Invalid values are used to indicate an optional key should not be emitted. + const uint8_t INVALID_ADDR_QUAL = 0xff; + const uint8_t INVALID_ACC_QUAL = 0xff; + const uint32_t INVALID_KERNEL_INDEX = ~0U; + + namespace KernelArg { + + // In-memory representation of kernel argument information. + struct Metadata { + uint32_t Size = 0; + uint32_t Align = 0; + uint32_t PointeeAlign = 0; + uint8_t Kind = 0; + uint16_t ValueType = 0; + std::string TypeName; + std::string Name; + uint8_t AddrQual = INVALID_ADDR_QUAL; + uint8_t AccQual = INVALID_ACC_QUAL; + uint8_t IsVolatile = 0; + uint8_t IsConst = 0; + uint8_t IsRestrict = 0; + uint8_t IsPipe = 0; + + Metadata() = default; + }; + + } // end namespace KernelArg + + namespace Kernel { + + // In-memory representation of kernel information. + struct Metadata { + std::string Name; + std::string Language; + std::vector LanguageVersion; + std::vector ReqdWorkGroupSize; + std::vector WorkGroupSizeHint; + std::string VecTypeHint; + uint32_t KernelIndex = INVALID_KERNEL_INDEX; + uint8_t NoPartialWorkGroups = 0; + std::vector Args; + + Metadata() = default; + }; + + } // end namespace Kernel + + namespace IsaInfo { + + /// \brief In-memory representation of instruction set architecture + /// information. + struct Metadata { + /// \brief Wavefront size. + unsigned WavefrontSize = 0; + /// \brief Local memory size in bytes. + unsigned LocalMemorySize = 0; + /// \brief Number of execution units per compute unit. + unsigned EUsPerCU = 0; + /// \brief Maximum number of waves per execution unit. + unsigned MaxWavesPerEU = 0; + /// \brief Maximum flat work group size. + unsigned MaxFlatWorkGroupSize = 0; + /// \brief SGPR allocation granularity. + unsigned SGPRAllocGranule = 0; + /// \brief Total number of SGPRs. + unsigned TotalNumSGPRs = 0; + /// \brief Addressable number of SGPRs. + unsigned AddressableNumSGPRs = 0; + /// \brief VGPR allocation granularity. + unsigned VGPRAllocGranule = 0; + /// \brief Total number of VGPRs. + unsigned TotalNumVGPRs = 0; + /// \brief Addressable number of VGPRs. + unsigned AddressableNumVGPRs = 0; + + Metadata() = default; + }; + + } // end namespace IsaInfo + + namespace Program { + + // In-memory representation of program information. + struct Metadata { + std::vector MDVersionSeq; + IsaInfo::Metadata IsaInfo; + std::vector PrintfInfo; + std::vector Kernels; + + explicit Metadata() = default; + + // Construct from an YAML string. + explicit Metadata(const std::string &YAML); + + // Convert to YAML string. + std::string toYAML(); + + // Convert from YAML string. + static Metadata fromYAML(const std::string &S); + }; + + } //end namespace Program + +} // end namespace RuntimeMD +} // end namespace AMDGPU + +#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp new file mode 100644 index 0000000000..10d8d3ab89 --- /dev/null +++ b/projects/hip/src/device_functions.cpp @@ -0,0 +1,593 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#include +#include +#include +#include +#include "device_util.h" + +struct holder64Bit{ + union{ + double d; + unsigned long int uli; + signed long int sli; + signed int si[2]; + unsigned int ui[2]; + }; +} __attribute__((aligned(8))); + +struct holder32Bit { + union { + float f; + unsigned int ui; + signed int si; + }; +} __attribute__((aligned(4))); + +__device__ struct holder64Bit hold64; +__device__ struct holder32Bit hold32; + +__device__ float __double2float_rd(double x) +{ + return (double)x; +} +__device__ float __double2float_rn(double x) +{ + return (double)x; +} +__device__ float __double2float_ru(double x) +{ + return (double)x; +} +__device__ float __double2float_rz(double x) +{ + return (double)x; +} + + +__device__ int __double2hiint(double x) +{ + hold64.d = x; + return hold64.si[1]; +} +__device__ int __double2loint(double x) +{ + hold64.d = x; + return hold64.si[0]; +} + + +__device__ int __double2int_rd(double x) +{ + return (int)x; +} +__device__ int __double2int_rn(double x) +{ + return (int)x; +} +__device__ int __double2int_ru(double x) +{ + return (int)x; +} +__device__ int __double2int_rz(double x) +{ + return (int)x; +} + +__device__ long long int __double2ll_rd(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_rn(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_ru(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_rz(double x) +{ + return (long long int)x; +} + + +__device__ unsigned int __double2uint_rd(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_rn(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_ru(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_rz(double x) +{ + return (unsigned int)x; +} + +__device__ unsigned long long int __double2ull_rd(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_rn(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_ru(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_rz(double x) +{ + return (unsigned long long int)x; +} + +__device__ long long int __double_as_longlong(double x) +{ + hold64.d = x; + return hold64.sli; +} + +__device__ int float2int_rd(float x) +{ + return (int)x; +} +__device__ int float2int_rn(float x) +{ + return (int)x; +} +__device__ int float2int_ru(float x) +{ + return (int)x; +} +__device__ int float2int_rz(float x) +{ + return (int)x; +} + +__device__ long long int __float2ll_rd(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_rn(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_ru(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_rz(float x) +{ + return (long long int)x; +} + +__device__ unsigned int __float2uint_rd(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_rn(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_ru(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_rz(float x) +{ + return (unsigned int)x; +} + +__device__ unsigned long long int __float2ull_rd(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_rn(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_ru(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_rz(float x) +{ + return (unsigned long long int)x; +} + +__device__ int __float_as_int(float x) +{ + hold32.f = x; + return hold32.si; +} +__device__ unsigned int __float_as_uint(float x) +{ + hold32.f = x; + return hold32.ui; +} +__device__ double __hiloint2double(int hi, int lo) +{ + hold64.si[1] = hi; + hold64.si[0] = lo; + return hold64.d; +} +__device__ double __int2double_rn(int x) +{ + return (double)x; +} + +__device__ float __int2float_rd(int x) +{ + return (float)x; +} +__device__ float __int2float_rn(int x) +{ + return (float)x; +} +__device__ float __int2float_ru(int x) +{ + return (float)x; +} +__device__ float __int2float_rz(int x) +{ + return (float)x; +} + +__device__ float __int_as_float(int x) +{ + hold32.si = x; + return hold32.f; +} + +__device__ double __ll2double_rd(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_rn(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_ru(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_rz(long long int x) +{ + return (double)x; +} + +__device__ float __ll2float_rd(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_rn(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_ru(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_rz(long long int x) +{ + return (float)x; +} + +__device__ double __longlong_as_double(long long int x) +{ + hold64.sli = x; + return hold64.d; +} + +__device__ double __uint2double_rn(int x) +{ + return (double)x; +} + +__device__ float __uint2float_rd(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_rn(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_ru(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_rz(unsigned int x) +{ + return (float)x; +} + +__device__ float __uint_as_float(unsigned int x) +{ + hold32.ui = x; + return hold32.f; +} + +__device__ double __ull2double_rd(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_rn(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_ru(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_rz(unsigned long long int x) +{ + return (double)x; +} + +__device__ float __ull2float_rd(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_rn(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_ru(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_rz(unsigned long long int x) +{ + return (float)x; +} + +/* +Integer Intrinsics +*/ + +// integer intrinsic function __poc __clz __ffs __brev +__device__ unsigned int __popc( unsigned int input) +{ + return hc::__popcount_u32_b32(input); +} + +__device__ unsigned int __popcll( unsigned long long int input) +{ + return hc::__popcount_u32_b64(input); +} + +__device__ unsigned int __clz(unsigned int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 32 : hc::__firstbit_u32_u32( input); +#else + return hc::__firstbit_u32_u32( input); +#endif +} + +__device__ unsigned int __clzll(unsigned long long int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 64 : hc::__firstbit_u32_u64( input); +#else + return hc::__firstbit_u32_u64( input); +#endif +} + +__device__ unsigned int __clz( int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 32 : hc::__firstbit_u32_s32( input); +#else + return hc::__firstbit_u32_s32( input); +#endif +} + +__device__ unsigned int __clzll( long long int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 64 : hc::__firstbit_u32_s64( input); +#else + return hc::__firstbit_u32_s64( input); +#endif +} + +__device__ unsigned int __ffs(unsigned int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_u32( input)+1; +#else + return hc::__lastbit_u32_u32( input); +#endif +} + +__device__ unsigned int __ffsll(unsigned long long int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_u64( input)+1; +#else + return hc::__lastbit_u32_u64( input); +#endif +} + +__device__ unsigned int __ffs( int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_s32( input)+1; +#else + return hc::__lastbit_u32_s32( input); +#endif +} + +__device__ unsigned int __ffsll( long long int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_s64( input)+1; +#else + return hc::__lastbit_u32_s64( input); +#endif +} + +__device__ unsigned int __brev( unsigned int input) +{ + return hc::__bitrev_b32( input); +} + +__device__ unsigned long long int __brevll( unsigned long long int input) +{ + return hc::__bitrev_b64( input); +} + +struct ucharHolder { + union { + unsigned char c[4]; + unsigned int ui; + }; +}__attribute__((aligned(4))); + +struct uchar2Holder { + union { + unsigned int ui[2]; + unsigned char c[8]; + }; +}__attribute__((aligned(8))); + +struct intHolder { + union { + signed int si[2]; + signed int long sl; + }; +}__attribute__((aligned(8))); + +struct uintHolder { + union { + signed int ui[2]; + signed int long ul; + }; +}__attribute__((aligned(8))); + + +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s) +{ + struct uchar2Holder cHoldVal; + struct ucharHolder cHoldKey; + struct ucharHolder cHoldOut; + cHoldKey.ui = s; + cHoldVal.ui[0] = x; + cHoldVal.ui[1] = y; + cHoldOut.c[0] = cHoldVal.c[cHoldKey.c[0]]; + cHoldOut.c[1] = cHoldVal.c[cHoldKey.c[1]]; + cHoldOut.c[2] = cHoldVal.c[cHoldKey.c[2]]; + cHoldOut.c[3] = cHoldVal.c[cHoldKey.c[3]]; + return cHoldOut.ui; +} + +__device__ long long __mul64hi(long long int x, long long int y) +{ + struct intHolder iHold1; + struct intHolder iHold2; + iHold1.sl = x; + iHold2.sl = y; + iHold1.sl = iHold1.si[1] * iHold2.si[1]; + return iHold1.sl; +} + +__device__ unsigned long long __umul64hi(unsigned long long int x, unsigned long long int y) +{ + struct uintHolder uHold1; + struct uintHolder uHold2; + uHold1.ul = x; + uHold2.ul = y; + uHold1.ul = uHold1.ui[1] * uHold2.ui[1]; + return uHold1.ul; +} + +/* +HIP specific device functions +*/ + +__device__ unsigned __hip_ds_bpermute(int index, unsigned src) { + return hc::__amdgcn_ds_bpermute(index, src); +} + +__device__ float __hip_ds_bpermutef(int index, float src) { + return hc::__amdgcn_ds_bpermute(index, src); +} + +__device__ unsigned __hip_ds_permute(int index, unsigned src) { + return hc::__amdgcn_ds_permute(index, src); +} + +__device__ float __hip_ds_permutef(int index, float src) { + return hc::__amdgcn_ds_permute(index, src); +} + +__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern) { + return hc::__amdgcn_ds_swizzle(src, pattern); +} + +__device__ float __hip_ds_swizzlef(float src, int pattern) { + return hc::__amdgcn_ds_swizzle(src, pattern); +} + +__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl) { + return hc::__amdgcn_move_dpp(src, dpp_ctrl, row_mask, bank_mask, bound_ctrl); +} + +#define MASK1 0x00ff00ff +#define MASK2 0xff00ff00 + +__device__ char4 __hip_hc_add8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 + one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 + one2) & MASK2); + return out; +} + +__device__ char4 __hip_hc_sub8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 - one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 - one2) & MASK2); + return out; +} + +__device__ char4 __hip_hc_mul8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 * one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 * one2) & MASK2); + return out; +} diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 7efb12d2d0..8ce53765b5 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -14,7 +14,8 @@ 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, +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. */ @@ -23,7 +24,7 @@ THE SOFTWARE. #include #include #include "device_util.h" - +#include "hip/hcc_detail/device_functions.h" #include "hip/hip_runtime.h" //================================================================================================= @@ -33,8 +34,8 @@ THE SOFTWARE. This is the best place to put them because the device global variables need to be initialized at the start. */ -__attribute__((address_space(1))) char gpuHeap[SIZE_OF_HEAP]; -__attribute__((address_space(1))) uint32_t gpuFlags[NUM_PAGES]; +__device__ ADDRESS_SPACE_1 char gpuHeap[SIZE_OF_HEAP]; +__device__ ADDRESS_SPACE_1 uint32_t gpuFlags[NUM_PAGES]; __device__ void *__hip_hc_malloc(size_t size) { @@ -95,72 +96,10 @@ __device__ void* __hip_hc_free(void *ptr) return nullptr; } -__device__ unsigned __hip_ds_bpermute(int index, unsigned src) { - return hc::__amdgcn_ds_bpermute(index, src); -} -__device__ float __hip_ds_bpermutef(int index, float src) { - return hc::__amdgcn_ds_bpermute(index, src); -} - -__device__ unsigned __hip_ds_permute(int index, unsigned src) { - return hc::__amdgcn_ds_permute(index, src); -} - -__device__ float __hip_ds_permutef(int index, float src) { - return hc::__amdgcn_ds_permute(index, src); -} - -__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern) { - return hc::__amdgcn_ds_swizzle(src, pattern); -} - -__device__ float __hip_ds_swizzlef(float src, int pattern) { - return hc::__amdgcn_ds_swizzle(src, pattern); -} - -__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl) { - return hc::__amdgcn_move_dpp(src, dpp_ctrl, row_mask, bank_mask, bound_ctrl); -} - -#define MASK1 0x00ff00ff -#define MASK2 0xff00ff00 - -__device__ char4 __hip_hc_add8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 + one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 + one2) & MASK2); - return out; -} - -__device__ char4 __hip_hc_sub8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 - one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 - one2) & MASK2); - return out; -} - -__device__ char4 __hip_hc_mul8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 * one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 * one2) & MASK2); - return out; -} // loop unrolling -__device__ void* memcpy(void* dst, void* src, size_t size) +__device__ void* __hip_hc_memcpy(void* dst, const void* src, size_t size) { uint8_t *dstPtr, *srcPtr; dstPtr = (uint8_t*)dst; @@ -171,7 +110,7 @@ __device__ void* memcpy(void* dst, void* src, size_t size) return nullptr; } -__device__ void* memset(void* ptr, uint8_t val, size_t size) +__device__ void* __hip_hc_memset(void* ptr, uint8_t val, size_t size) { uint8_t *dstPtr; dstPtr = (uint8_t*)ptr; @@ -181,49 +120,6 @@ __device__ void* memset(void* ptr, uint8_t val, size_t size) return nullptr; } -__device__ void* malloc(size_t size) -{ - return __hip_hc_malloc(size); -} - -__device__ void* free(void *ptr) -{ - return __hip_hc_free(ptr); -} - -//================================================================================================= - -// TODO: Choose whether default is precise math or fast math based on compilation flag. -#ifdef __HCC_ACCELERATOR__ -using namespace hc::precise_math; -#endif - - -#define HIP_SQRT_2 1.41421356237 -#define HIP_SQRT_PI 1.77245385091 - -#define __hip_erfinva3 -0.140543331 -#define __hip_erfinva2 0.914624893 -#define __hip_erfinva1 -1.645349621 -#define __hip_erfinva0 0.886226899 - -#define __hip_erfinvb4 0.012229801 -#define __hip_erfinvb3 -0.329097515 -#define __hip_erfinvb2 1.442710462 -#define __hip_erfinvb1 -2.118377725 -#define __hip_erfinvb0 1 - -#define __hip_erfinvc3 1.641345311 -#define __hip_erfinvc2 3.429567803 -#define __hip_erfinvc1 -1.62490649 -#define __hip_erfinvc0 -1.970840454 - -#define __hip_erfinvd2 1.637067800 -#define __hip_erfinvd1 3.543889200 -#define __hip_erfinvd0 1 - -#define HIP_PI 3.14159265358979323846 - __device__ float __hip_erfinvf(float x){ float ret; int sign; @@ -939,739 +835,6 @@ __device__ float __hip_ynf(int n, float x) return b0; } - - -__device__ float acosf(float x) -{ - return hc::precise_math::acosf(x); -} -__device__ float acoshf(float x) -{ - return hc::precise_math::acoshf(x); -} -__device__ float asinf(float x) -{ - return hc::precise_math::asinf(x); -} -__device__ float asinhf(float x) -{ - return hc::precise_math::asinhf(x); -} -__device__ float atan2f(float y, float x) -{ - return hc::precise_math::atan2f(x, y); -} -__device__ float atanf(float x) -{ - return hc::precise_math::atanf(x); -} -__device__ float atanhf(float x) -{ - return hc::precise_math::atanhf(x); -} -__device__ float cbrtf(float x) -{ - return hc::precise_math::cbrtf(x); -} -__device__ float ceilf(float x) -{ - return hc::precise_math::ceilf(x); -} -__device__ float copysignf(float x, float y) -{ - return hc::precise_math::copysignf(x, y); -} -__device__ float cosf(float x) -{ - return hc::precise_math::cosf(x); -} -__device__ float coshf(float x) -{ - return hc::precise_math::coshf(x); -} -__device__ float cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); -__device__ float erfcf(float x) -{ - return hc::precise_math::erfcf(x); -} -__device__ float erfcinvf(float y) -{ - return __hip_erfinvf(1 - y); -} -__device__ float erfcxf(float x) -{ - return hc::precise_math::expf(x*x)*hc::precise_math::erfcf(x); -} -__device__ float erff(float x) -{ - return hc::precise_math::erff(x); -} -__device__ float erfinvf(float y) -{ - return __hip_erfinvf(y); -} -__device__ float exp10f(float x) -{ - return hc::precise_math::exp10f(x); -} -__device__ float exp2f(float x) -{ - return hc::precise_math::exp2f(x); -} -__device__ float expf(float x) -{ - return hc::precise_math::expf(x); -} -__device__ float expm1f(float x) -{ - return hc::precise_math::expm1f(x); -} -__device__ float fabsf(float x) -{ - return hc::precise_math::fabsf(x); -} -__device__ float fdimf(float x, float y) -{ - return hc::precise_math::fdimf(x, y); -} -__device__ float fdividef(float x, float y) -{ - return x/y; -} -__device__ float floorf(float x) -{ - return hc::precise_math::floorf(x); -} -__device__ float fmaf(float x, float y, float z) -{ - return hc::precise_math::fmaf(x, y, z); -} -__device__ float fmaxf(float x, float y) -{ - return hc::precise_math::fmaxf(x, y); -} -__device__ float fminf(float x, float y) -{ - return hc::precise_math::fminf(x, y); -} -__device__ float fmodf(float x, float y) -{ - return hc::precise_math::fmodf(x, y); -} -__device__ float frexpf(float x, int *nptr) -{ - return hc::precise_math::frexpf(x, nptr); -} -__device__ float hypotf(float x, float y) -{ - return hc::precise_math::hypotf(x, y); -} -__device__ float ilogbf(float x) -{ - return hc::precise_math::ilogbf(x); -} -__device__ unsigned isfinite(float a) -{ - return hc::precise_math::isfinite(a); -} -__device__ unsigned isinf(float a) -{ - return hc::precise_math::isinf(a); -} -__device__ unsigned isnan(float a) -{ - return hc::precise_math::isnan(a); -} -__device__ float j0f(float x) -{ - return __hip_j0f(x); -} -__device__ float j1f(float x) -{ - return __hip_j1f(x); -} -__device__ float jnf(int n, float x) -{ - return __hip_jnf(n, x); -} -__device__ float ldexpf(float x, int exp) -{ - return hc::precise_math::ldexpf(x, exp); -} -__device__ float lgammaf(float x, int *sign) -{ - return hc::precise_math::lgammaf(x, sign); -} -__device__ long long int llrintf(float x) -{ - int y = hc::precise_math::roundf(x); - long long int z = y; - return z; -} -__device__ long long int llroundf(float x) -{ - int y = hc::precise_math::roundf(x); - long long int z = y; - return z; -}__device__ float log10f(float x) -{ - return hc::precise_math::log10f(x); -} -__device__ float log1pf(float x) -{ - return hc::precise_math::log1pf(x); -} -__device__ float log2f(float x) -{ - return hc::precise_math::log2f(x); -} -__device__ float logbf(float x) -{ - return hc::precise_math::logbf(x); -} -__device__ float logf(float x) -{ - return hc::precise_math::logf(x); -} -__device__ long int lrintf(float x) -{ - int y = hc::precise_math::roundf(x); - long int z = y; - return z; -} -__device__ long int lroundf(float x) -{ - long int y = hc::precise_math::roundf(x); - return y; -} -__device__ float modff(float x, float *iptr) -{ - return hc::precise_math::modff(x, iptr); -} -__device__ float nanf(const char* tagp) -{ - return hc::precise_math::nanf((int)*tagp); -} -__device__ float nearbyintf(float x) -{ - return hc::precise_math::nearbyintf(x); -} -__device__ float nextafterf(float x, float y) -{ - return hc::precise_math::nextafter(x, y); -} -__device__ float norm3df(float a, float b, float c) -{ - float x = a*a + b*b + c*c; - return hc::precise_math::sqrtf(x); -} -__device__ float norm4df(float a, float b, float c, float d) -{ - float x = a*a + b*b; - float y = c*c + d*d; - return hc::precise_math::sqrtf(x+y); -} - -__device__ float normcdff(float y) -{ - return ((hc::precise_math::erff(y)/1.41421356237) + 1)/2; -} -__device__ float normcdfinvf(float y) -{ - return HIP_SQRT_2 * __hip_erfinvf(2*y-1); -} -__device__ float normf(int dim, const float *a) -{ - float x = 0.0f; - for(int i=0;i(x); -} - -__HIP_DEVICE__ long long __double_as_longlong(double x) -{ - return static_cast(x); -} - -__HIP_DEVICE__ void __threadfence_system(void){ +__device__ void __threadfence_system(void){ // no-op } @@ -3208,187 +1842,3 @@ float __hip_host_ynf(int n, float x) } return b0; } - -__host__ float modff(float x, float *iptr) -{ - return std::modf(x, iptr); -} - -__host__ float erfcinvf(float y) -{ - return __hip_host_erfcinvf(y); -} - -__host__ double erfcinv(double y) -{ - return __hip_host_erfcinv(y); -} - -__host__ float erfinvf(float x) -{ - return __hip_host_erfinvf(x); -} - -__host__ double erfinv(double x) -{ - return __hip_host_erfinv(x); -} - -__host__ double fdivide(double x, double y) -{ - return x/y; -} - -__host__ float normcdff(float t) -{ - return (1 - std::erf(-t/std::sqrt(2)))/2; -} - -__host__ double normcdf(double x) -{ - return (1 - std::erf(-x/std::sqrt(2)))/2; -} - -__host__ float erfcxf(float x) -{ - return std::exp(x*x) * std::erfc(x); -} - -__host__ double erfcx(double x) -{ - return std::exp(x*x) * std::erfc(x); -} - -__host__ float rhypotf(float x, float y) -{ - return 1 / std::sqrt(x*x + y*y); -} - -__host__ double rhypot(double x, double y) -{ - return 1 / std::sqrt(x*x + y*y); -} - -__host__ float rcbrtf(float a) -{ - return 1 / std::cbrt(a); -} - -__host__ double rcbrt(double a) -{ - return 1 / std::cbrt(a); -} - -__host__ float normf(int dim, const float *a) -{ - float val = 0.0f; - for(int i=0;i + /* Heap size computation for malloc and free device functions. */ @@ -30,9 +32,124 @@ THE SOFTWARE. #define NUM_PAGES_PER_THREAD 16 #define SIZE_OF_PAGE 64 #define NUM_THREADS_PER_CU 64 -#define NUM_CUS_PER_GPU 64 +#define NUM_CUS_PER_GPU 64 // Specific for r9 Nano #define NUM_PAGES NUM_PAGES_PER_THREAD * NUM_THREADS_PER_CU * NUM_CUS_PER_GPU #define SIZE_MALLOC NUM_PAGES * SIZE_OF_PAGE #define SIZE_OF_HEAP SIZE_MALLOC +#define HIP_SQRT_2 1.41421356237 +#define HIP_SQRT_PI 1.77245385091 + +#define __hip_erfinva3 -0.140543331 +#define __hip_erfinva2 0.914624893 +#define __hip_erfinva1 -1.645349621 +#define __hip_erfinva0 0.886226899 + +#define __hip_erfinvb4 0.012229801 +#define __hip_erfinvb3 -0.329097515 +#define __hip_erfinvb2 1.442710462 +#define __hip_erfinvb1 -2.118377725 +#define __hip_erfinvb0 1 + +#define __hip_erfinvc3 1.641345311 +#define __hip_erfinvc2 3.429567803 +#define __hip_erfinvc1 -1.62490649 +#define __hip_erfinvc0 -1.970840454 + +#define __hip_erfinvd2 1.637067800 +#define __hip_erfinvd1 3.543889200 +#define __hip_erfinvd0 1 + +#define HIP_PI 3.14159265358979323846 + +__device__ void* __hip_hc_malloc(size_t size); +__device__ void* __hip_hc_free(void* ptr); + +__device__ float __hip_erfinvf(float x); +__device__ double __hip_erfinv(double x); + +__device__ float __hip_j0f(float x); +__device__ double __hip_j0(double x); + +__device__ float __hip_j1f(float x); +__device__ double __hip_j1(double x); + +__device__ float __hip_y0f(float x); +__device__ double __hip_y0(double x); + +__device__ float __hip_y1f(float x); +__device__ double __hip_y1(double x); + +__device__ float __hip_jnf(int n, float x); +__device__ double __hip_jn(int n, double x); + +__device__ float __hip_ynf(int n, float x); +__device__ double __hip_yn(int n, double x); + +__device__ float __hip_precise_cosf(float x); +__device__ float __hip_precise_exp10f(float x); +__device__ float __hip_precise_expf(float x); +__device__ float __hip_precise_frsqrt_rn(float x); +__device__ float __hip_precise_fsqrt_rd(float x); +__device__ float __hip_precise_fsqrt_rn(float x); +__device__ float __hip_precise_fsqrt_ru(float x); +__device__ float __hip_precise_fsqrt_rz(float x); +__device__ float __hip_precise_log10f(float x); +__device__ float __hip_precise_log2f(float x); +__device__ float __hip_precise_logf(float x); +__device__ float __hip_precise_powf(float base, float exponent); +__device__ void __hip_precise_sincosf(float x, float *s, float *c); +__device__ float __hip_precise_sinf(float x); +__device__ float __hip_precise_tanf(float x); +// Double Precision Math +__device__ double __hip_precise_dsqrt_rd(double x); +__device__ double __hip_precise_dsqrt_rn(double x); +__device__ double __hip_precise_dsqrt_ru(double x); +__device__ double __hip_precise_dsqrt_rz(double x); + + + +// Float Fast Math +__device__ float __hip_fast_exp10f(float x); +__device__ float __hip_fast_expf(float x); +__device__ float __hip_fast_frsqrt_rn(float x); +__device__ float __hip_fast_fsqrt_rn(float x); +__device__ float __hip_fast_fsqrt_ru(float x); +__device__ float __hip_fast_fsqrt_rz(float x); +__device__ float __hip_fast_log10f(float x); +__device__ float __hip_fast_logf(float x); +__device__ float __hip_fast_powf(float base, float exponent); +__device__ void __hip_fast_sincosf(float x, float *s, float *c); +__device__ float __hip_fast_tanf(float x); +// Double Precision Math +__device__ double __hip_fast_dsqrt_rd(double x); +__device__ double __hip_fast_dsqrt_rn(double x); +__device__ double __hip_fast_dsqrt_ru(double x); +__device__ double __hip_fast_dsqrt_rz(double x); +__device__ void __threadfence_system(void); + +float __hip_host_erfinvf(float x); +double __hip_host_erfinv(double x); + +float __hip_host_erfcinvf(float y); +double __hip_host_erfcinv(double y); + +float __hip_host_j0f(float x); +double __hip_host_j0(double x); + +float __hip_host_j1f(float x); +double __hip_host_j1(double x); + +float __hip_host_y0f(float x); +double __hip_host_y1(double x); + +float __hip_host_y1f(float x); +double __hip_host_y1(double x); + +float __hip_host_jnf(int n, float x); +double __hip_host_jn(int n, double x); + +float __hip_host_ynf(int n, float x); +double __hip_host_yn(int n, double x); + #endif diff --git a/projects/hip/src/env.cpp b/projects/hip/src/env.cpp new file mode 100644 index 0000000000..0899784592 --- /dev/null +++ b/projects/hip/src/env.cpp @@ -0,0 +1,113 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#include "hip_hcc_internal.h" +#include "trace_helper.h" +#include "env.h" + +//--- +// Read environment variables. +void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + // Default is set when variable is initialized (at top of this file), so only override if we find + // an environment variable. + if (env) { + long int v = strtol(env, NULL, 0); + *var_ptr = (int) (v); + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %2d : %s\n", var_name1, *var_ptr, description); + } +} + + +void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + if (env) { + *static_cast(var_ptr) = env; + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %s : %s\n", var_name1, var_ptr->c_str(), description); + } +} + + +void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + std::string var_string = "0"; + if (env) { + var_string = setterCallback(var_ptr, env); + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %s : %s\n", var_name1, var_string.c_str(), description); + } +} + + + + +void tokenize(const std::string &s, char delim, std::vector *tokens) +{ + std::stringstream ss; + ss.str(s); + std::string item; + while (getline(ss, item, delim)) { + item.erase (std::remove (item.begin(), item.end(), ' '), item.end()); // remove whitespace. + tokens->push_back(item); + } +} + +void trim(std::string *s) +{ + // trim whitespace from beginning and end: + const char *t = "\t\n\r\f\v"; + s->erase(0, s->find_first_not_of(t)); + s->erase(s->find_last_not_of(t)+1); +} + +static void ltrim(std::string *s) +{ + // trim whitespace from beginning + const char *t = "\t\n\r\f\v"; + s->erase(0, s->find_first_not_of(t)); +} diff --git a/projects/hip/src/env.h b/projects/hip/src/env.h new file mode 100644 index 0000000000..d1ec36f0c8 --- /dev/null +++ b/projects/hip/src/env.h @@ -0,0 +1,24 @@ +#pragma once + +extern void HipReadEnv(); + + + +#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ + ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description); + +#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ + ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description); + +#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ + ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback); + + +extern void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description); +extern void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description); +extern void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)); + + +// String functions: +extern void trim(std::string *s); +extern void tokenize(const std::string &s, char delim, std::vector *tokens); diff --git a/projects/hip/src/grid_launch.cpp b/projects/hip/src/grid_launch.cpp new file mode 100644 index 0000000000..cac01df7dc --- /dev/null +++ b/projects/hip/src/grid_launch.cpp @@ -0,0 +1,96 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#include "hip/hcc_detail/grid_launch_GGL.hpp" + +// Internal header, do not percolate upwards. +#include "hip_hcc_internal.h" +#include "hc.hpp" +#include "trace_helper.h" + +#include +#include + +namespace hip_impl +{ + hc::accelerator_view lock_stream_hip_( + hipStream_t& stream, void*& locked_stream) + { // This allocated but does not take ownership of locked_stream. If it is + // not deleted elsewhere it will leak. + using L = decltype(stream->lockopen_preKernelCommand()); + + HIP_INIT(); + + stream = ihipSyncAndResolveStream(stream); + locked_stream = new L{stream->lockopen_preKernelCommand()}; + return (*static_cast(locked_stream))->_av; + } + + void print_prelaunch_trace_( + const char* kernel_name, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream) + { + if ((HIP_TRACE_API & (1 << TRACE_CMD)) || + HIP_PROFILE_API || + (COMPILE_HIP_DB && HIP_TRACE_API)) { + std::stringstream os; + os << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() + << " hipLaunchKernel '" << kernel_name << "'" + << " gridDim:" << num_blocks + << " groupDim:" << dim_blocks + << " sharedMem:+" << group_mem_bytes + << " " << *stream; + + if (HIP_PROFILE_API == 0x1) { + std::string shortAtpString("hipLaunchKernel:"); + shortAtpString += kernel_name; + MARKER_BEGIN(shortAtpString.c_str(), "HIP"); + } else if (HIP_PROFILE_API == 0x2) { + MARKER_BEGIN(os.str().c_str(), "HIP"); + } + + if (COMPILE_HIP_DB && HIP_TRACE_API) { + std::cerr << API_COLOR << os.str() << API_COLOR_END + << std::endl; + } + } + } + + void unlock_stream_hip_( + hipStream_t stream, + void* locked_stream, + const char* kernel_name, + hc::accelerator_view* acc_v) + { // Precondition: acc_v is the accelerator_view associated with stream + // which is guarded by locked_stream; + // locked_stream is deletable. + using L = decltype(stream->lockopen_preKernelCommand()); + + stream->lockclose_postKernelCommand(kernel_name, acc_v); + + delete static_cast(locked_stream); + locked_stream = nullptr; + } +} diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index 8a2451671c..11ef6d6da5 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" // Stack of contexts @@ -57,10 +57,16 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device) { HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init hipError_t e = hipSuccess; - - *ctx = new ihipCtx_t(device, g_deviceCnt, flags); - ihipSetTlsDefaultCtx(*ctx); - tls_ctxStack.push(*ctx); + auto deviceHandle = ihipGetDevice(device); + { + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_DeviceCrit_t deviceCrit(deviceHandle->criticalData()); + auto ictx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags); + *ctx = ictx; + ihipSetTlsDefaultCtx(*ctx); + tls_ctxStack.push(*ctx); + deviceCrit->addContext(ictx); + } return ihipLogStatus(e); } @@ -69,11 +75,13 @@ hipError_t hipDeviceGet(hipDevice_t *device, int deviceId) { HIP_INIT_API(device, deviceId); // FIXME - review if we want to init - *device = ihipGetDevice(deviceId); + auto deviceHandle = ihipGetDevice(deviceId); hipError_t e = hipSuccess; - if (*device == NULL) { + if (deviceHandle == NULL) { e = hipErrorInvalidDevice; + } else { + *device = deviceId; } return ihipLogStatus(e); @@ -123,6 +131,11 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) //need to destroy the ctx associated with calling thread tls_ctxStack.pop(); } + { + auto deviceHandle = ctx->getWriteableDevice(); + deviceHandle->locked_removeContext(ctx); + ctx->locked_reset(); + } delete ctx; //As per CUDA docs , attempting to access ctx from those threads which has this ctx as current, will result in the error HIP_ERROR_CONTEXT_IS_DESTROYED. } @@ -199,9 +212,11 @@ hipError_t hipCtxGetDevice(hipDevice_t *device) if(ctx == nullptr) { e = hipErrorInvalidContext; + // TODO *device = nullptr; } else { - *device = (ihipDevice_t*)ctx->getDevice(); + auto deviceHandle = ctx->getDevice(); + *device = deviceHandle->_deviceId; } return ihipLogStatus(e); } @@ -268,3 +283,79 @@ hipError_t hipCtxGetFlags ( unsigned int* flags ) *flags = tempCtx->_ctxFlags; return ihipLogStatus(e); } + +hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ) +{ + HIP_INIT_API(dev, flags, active); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + + ihipCtx_t* tempCtx; + tempCtx = ihipGetTlsDefaultCtx(); + ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx; + if(tempCtx == primaryCtx) { + *active = 1; + *flags = tempCtx->_ctxFlags; + } else { + *active = 0; + *flags = primaryCtx->_ctxFlags; + } + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev) +{ + HIP_INIT_API(dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ) +{ + HIP_INIT_API(pctx, dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + *pctx = deviceHandle->_primaryCtx; + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ) +{ + HIP_INIT_API(dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx; + primaryCtx->locked_reset(); + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ) +{ + HIP_INIT_API(dev, flags); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } else { + e = hipErrorContextAlreadyInUse; + } + return ihipLogStatus(e); +} diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index bf45125b60..88d94411e8 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" #include "device_util.h" @@ -166,15 +166,38 @@ hipError_t hipDeviceReset(void) // This function currently does a user-level cleanup of known resources. // It could benefit from KFD support to perform a more "nuclear" clean that would include any associated kernel resources and page table entries. - +#if 0 if (ctx) { // Release ctx resources (streams and memory): ctx->locked_reset(); } +#endif + if (ctx) { + ihipDevice_t *deviceHandle = ctx->getWriteableDevice(); + deviceHandle->locked_reset(); + } return ihipLogStatus(hipSuccess); } +hipError_t ihipDeviceSetState(void) +{ + hipError_t e = hipErrorInvalidContext; + auto *ctx = ihipGetTlsDefaultCtx(); + + if (ctx) { + ihipDevice_t *deviceHandle = ctx->getWriteableDevice(); + if(deviceHandle->_state == 0) + { + deviceHandle->_state = 1; + } + e = hipSuccess; + } + + return e; +} + + hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { hipError_t e = hipSuccess; @@ -243,13 +266,13 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device } else { e = hipErrorInvalidDevice; } - return ihipLogStatus(e); + return e; } hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { HIP_INIT_API(pi, attr, device); - return ihipDeviceGetAttribute(pi,attr,device); + return ihipLogStatus(ihipDeviceGetAttribute(pi,attr,device)); } hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) @@ -269,7 +292,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) e = hipErrorInvalidDevice; } - return ihipLogStatus(e); + return e; } hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) @@ -289,29 +312,35 @@ hipError_t hipSetDeviceFlags( unsigned int flags) // TODO : does this really OR in the flags or replaces previous flags: // TODO : Review error handling behavior for this function, it often returns ErrorSetOnActiveProcess if (ctx) { - ctx->_ctxFlags = ctx->_ctxFlags | flags; - if (flags & hipDeviceScheduleMask) { - switch (hipDeviceScheduleMask) { - case hipDeviceScheduleAuto: - case hipDeviceScheduleSpin: - case hipDeviceScheduleYield: - case hipDeviceScheduleBlockingSync: - e = hipSuccess; - break; - default: - e = hipSuccess; // TODO - should this be error? Map to Auto? - //e = hipErrorInvalidValue; - break; + auto *deviceHandle = ctx->getDevice(); + if(deviceHandle->_state == 0) + { + ctx->_ctxFlags = ctx->_ctxFlags | flags; + if (flags & hipDeviceScheduleMask) { + switch (hipDeviceScheduleMask) { + case hipDeviceScheduleAuto: + case hipDeviceScheduleSpin: + case hipDeviceScheduleYield: + case hipDeviceScheduleBlockingSync: + e = hipSuccess; + break; + default: + e = hipSuccess; // TODO - should this be error? Map to Auto? + //e = hipErrorInvalidValue; + break; + } } - } - unsigned supportedFlags = hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax; + unsigned supportedFlags = hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax; - if (flags & (~supportedFlags)) { - e = hipErrorInvalidValue; - } - } else { - e = hipErrorInvalidDevice; + if (flags & (~supportedFlags)) { + e = hipErrorInvalidValue; + } + } else { + e = hipErrorSetOnActiveProcess; + } + } else { + e = hipErrorInvalidDevice; } return ihipLogStatus(e); @@ -321,9 +350,8 @@ hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device { HIP_INIT_API(major,minor, device); hipError_t e = hipSuccess; - int deviceId= device->_deviceId; - e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, deviceId); - e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, deviceId); + e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, device); + e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, device); return ihipLogStatus(e); } @@ -331,28 +359,13 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) { HIP_INIT_API(name,len, device); hipError_t e = hipSuccess; - int nameLen = strlen(device->_props.name); + auto deviceHandle = ihipGetDevice(device); + int nameLen = strlen(deviceHandle->_props.name); if(nameLen <= len) - memcpy(name,device->_props.name,nameLen); + memcpy(name,deviceHandle->_props.name,nameLen); return ihipLogStatus(e); } -#ifdef __cplusplus -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device) -{ - HIP_INIT_API(pciBusId, len, device); - hipError_t e = hipSuccess; - int deviceId= device->_deviceId; - int tempPciBusId = 0; - e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, deviceId); - if( e == hipSuccess) { - std::string tempPciStr = std::to_string(tempPciBusId); - memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() ); - } - return ihipLogStatus(e); -} -#endif - hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) { HIP_INIT_API(pciBusId, len, device); @@ -365,11 +378,13 @@ hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) } return ihipLogStatus(e); } + hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device) { HIP_INIT_API(bytes, device); hipError_t e = hipSuccess; - *bytes= device->_props.totalGlobalMem; + auto deviceHandle = ihipGetDevice(device); + *bytes= deviceHandle->_props.totalGlobalMem; return ihipLogStatus(e); } @@ -469,4 +484,3 @@ hipError_t hipChooseDevice( int* device, const hipDeviceProp_t* prop ) } return ihipLogStatus(e); } - diff --git a/projects/hip/src/hip_error.cpp b/projects/hip/src/hip_error.cpp index 60c45cc1f7..21d5b6aa85 100644 --- a/projects/hip/src/hip_error.cpp +++ b/projects/hip/src/hip_error.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //------------------------------------------------------------------------------------------------- diff --git a/projects/hip/src/hip_event.cpp b/projects/hip/src/hip_event.cpp index 74fe487968..61ac5cd3ab 100644 --- a/projects/hip/src/hip_event.cpp +++ b/projects/hip/src/hip_event.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //------------------------------------------------------------------------------------------------- @@ -30,6 +30,54 @@ THE SOFTWARE. //--- +ihipEvent_t::ihipEvent_t(unsigned flags) +{ + _state = hipEventStatusCreated; + _stream = NULL; + _flags = flags; + _timestamp = 0; + _type = hipEventTypeIndependent; +}; + + + +// Attach to an existing completion future: +void ihipEvent_t::attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType) +{ + _state = hipEventStatusRecording; + _marker = *cf; + _type = eventType; +} + + + +void ihipEvent_t::setTimestamp() +{ + if (_state == hipEventStatusRecorded) { + // already recorded, done: + return; + } else { + // TODO - use completion-future functions to obtain ticks and timestamps: + hsa_signal_t *sig = static_cast (_marker.get_native_handle()); + if (sig) { + if (hsa_signal_load_acquire(*sig) == 0) { + + if ((_type == hipEventTypeIndependent) || (_type == hipEventTypeStopCommand)) { + _timestamp = _marker.get_end_tick(); + } else if (_type == hipEventTypeStartCommand) { + _timestamp = _marker.get_begin_tick(); + } else { + assert(0); // TODO - move to debug assert + _timestamp = 0; + } + + _state = hipEventStatusRecorded; + } + } + } +} + + hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) { hipError_t e = hipSuccess; @@ -37,13 +85,9 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) // TODO-IPC - support hipEventInterprocess. unsigned supportedFlags = hipEventDefault | hipEventBlockingSync | hipEventDisableTiming; if ((flags & ~supportedFlags) == 0) { - ihipEvent_t *eh = new ihipEvent_t(); + ihipEvent_t *eh = new ihipEvent_t(flags); - eh->_state = hipEventStatusCreated; - eh->_stream = NULL; - eh->_flags = flags; - eh->_timestamp = 0; - *event = eh; + *event = eh; } else { e = hipErrorInvalidValue; } @@ -141,8 +185,8 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) ihipEvent_t *start_eh = start; ihipEvent_t *stop_eh = stop; - ihipSetTs(start); - ihipSetTs(stop); + start->setTimestamp(); + stop->setTimestamp(); hipError_t status = hipSuccess; *ms = 0.0f; @@ -151,7 +195,7 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) if ((start_eh->_state == hipEventStatusRecorded) && (stop_eh->_state == hipEventStatusRecorded)) { // Common case, we have good information for both events. - int64_t tickDiff = (stop_eh->_timestamp - start_eh->_timestamp); + int64_t tickDiff = (stop_eh->timestamp() - start_eh->timestamp()); uint64_t freqHz; hsa_system_get_info(HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY, &freqHz); @@ -186,5 +230,3 @@ hipError_t hipEventQuery(hipEvent_t event) return ihipLogStatus(hipSuccess); } } - - diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 1a9d04474f..c2b7b47597 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,514 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include"hip/hip_fp16.h" +#include"hip/hcc_detail/hip_fp16.h" + +struct hipHalfHolder{ + union { + __half h; + unsigned short s; + }; +}; + +#define HINF 65504 + +__device__ static struct hipHalfHolder __hInfValue = {HINF}; + +__device__ __half __hadd(__half a, __half b) { + return a + b; +} + +__device__ __half __hadd_sat(__half a, __half b) { + return a + b; +} + +__device__ __half __hfma(__half a, __half b, __half c) { + return a * b + c; +} + +__device__ __half __hfma_sat(__half a, __half b, __half c) { + return a * b + c; +} + +__device__ __half __hmul(__half a, __half b) { + return a * b; +} + +__device__ __half __hmul_sat(__half a, __half b) { + return a * b; +} + +__device__ __half __hneg(__half a) { + return -a; +} + +__device__ __half __hsub(__half a, __half b) { + return a - b; +} + +__device__ __half __hsub_sat(__half a, __half b) { + return a - b; +} + +__device__ __half hdiv(__half a, __half b) { + return a / b; +} + +/* +Half comparision Functions +*/ + +__device__ bool __heq(__half a, __half b) { + return a == b ? true : false; +} + +__device__ bool __hge(__half a, __half b) { + return a >= b ? true : false; +} + +__device__ bool __hgt(__half a, __half b) { + return a > b ? true : false; +} + +__device__ bool __hisinf(__half a) { + return a == __hInfValue.h ? true : false; +} + +__device__ bool __hisnan(__half a) { + return a > __hInfValue.h ? true : false; +} + +__device__ bool __hle(__half a, __half b) { + return a <= b ? true : false; +} + +__device__ bool __hlt(__half a, __half b) { + return a < b ? true : false; +} + +__device__ bool __hne(__half a, __half b) { + return a != b ? true : false; +} + +/* +Half2 Comparision Functions +*/ + +__device__ bool __hbeq2(__half2 a, __half2 b) { + return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false); +} + +__device__ bool __hbge2(__half2 a, __half2 b) { + return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false); +} + +__device__ bool __hbgt2(__half2 a, __half2 b) { + return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false); +} + +__device__ bool __hble2(__half2 a, __half2 b) { + return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false); +} + +__device__ bool __hblt2(__half2 a, __half2 b) { + return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false); +} + +__device__ bool __hbne2(__half2 a, __half2 b) { + return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); +} + +__device__ __half2 __heq2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] == b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] == b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hge2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] >= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] >= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hgt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] > b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hisnan2(__half2 a) { + __half2 c; + c.p[0] = (a.p[0] > __hInfValue.h) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > __hInfValue.h) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hle2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] <= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] <= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hlt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] < b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] < b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hne2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] != b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] != b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +/* +Conversion instructions +*/ +__device__ __half2 __float22half2_rn(const float2 a) { + __half2 b; + b.p[0] = (__half)a.x; + b.p[1] = (__half)a.y; + return b; +} + +__device__ __half __float2half(const float a) { + return (__half)a; +} + +__device__ __half2 __float2half2_rn(const float a) { + __half2 b; + b.p[0] = (__half)a; + b.p[1] = (__half)a; + return b; +} + +__device__ __half __float2half_rd(const float a) { + return (__half)a; +} + +__device__ __half __float2half_rn(const float a) { + return (__half)a; +} + +__device__ __half __float2half_ru(const float a) { + return (__half)a; +} + +__device__ __half __float2half_rz(const float a) { + return (__half)a; +} + +__device__ __half2 __floats2half2_rn(const float a, const float b) { + __half2 c; + c.p[0] = (__half)a; + c.p[1] = (__half)b; + return c; +} + +__device__ float2 __half22float2(const __half2 a) { + float2 b; + b.x = (float)a.p[0]; + b.y = (float)a.p[1]; + return b; +} + +__device__ float __half2float(const __half a) { + return (float)a; +} + +__device__ __half2 half2half2(const __half a) { + __half2 b; + b.p[0] = a; + b.p[1] = a; + return b; +} + +__device__ int __half2int_rd(__half h) { + return (int)h; +} + +__device__ int __half2int_rn(__half h) { + return (int)h; +} + +__device__ int __half2int_ru(__half h) { + return (int)h; +} + +__device__ int __half2int_rz(__half h) { + return (int)h; +} + +__device__ long long int __half2ll_rd(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_rn(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_ru(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_rz(__half h) { + return (long long int)h; +} + +__device__ short __half2short_rd(__half h) { + return (short)h; +} + +__device__ short __half2short_rn(__half h) { + return (short)h; +} + +__device__ short __half2short_ru(__half h) { + return (short)h; +} + +__device__ short __half2short_rz(__half h) { + return (short)h; +} + +__device__ unsigned int __half2uint_rd(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_rn(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_ru(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_rz(__half h) { + return (unsigned int)h; +} + +__device__ unsigned long long int __half2ull_rd(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_rn(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_ru(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_rz(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned short int __half2ushort_rd(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_rn(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_ru(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_rz(__half h) { + return (unsigned short int)h; +} + +__device__ short int __half_as_short(const __half h) { + hipHalfHolder hH; + hH.h = h; + return (short)hH.s; +} + +__device__ unsigned short int __half_as_ushort(const __half h) { + hipHalfHolder hH; + hH.h = h; + return hH.s; +} + +__device__ __half2 __halves2half2(const __half a, const __half b) { + __half2 c; + c.p[0] = a; + c.p[1] = b; + return c; +} + +__device__ float __high2float(const __half2 a) { + return (float)a.p[1]; +} + +__device__ __half __high2half(const __half2 a) { + return a.p[1]; +} + +__device__ __half2 __high2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[1]; + return b; +} + +__device__ __half2 __highs2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[1]; + c.p[1] = b.p[1]; + return c; +} + +__device__ __half __int2half_rd(int i) { + return (__half)i; +} + +__device__ __half __int2half_rn(int i) { + return (__half)i; +} + +__device__ __half __int2half_ru(int i) { + return (__half)i; +} + +__device__ __half __int2half_rz(int i) { + return (__half)i; +} + +__device__ __half __ll2half_rd(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_rn(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_ru(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_rz(long long int i){ + return (__half)i; +} + +__device__ float __low2float(const __half2 a) { + return (float)a.p[0]; +} + +__device__ __half __low2half(const __half2 a) { + return a.p[0]; +} + +__device__ __half2 __low2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ __half2 __low2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[0]; + b.p[1] = a.p[0]; + return b; +} + +__device__ __half2 __lowhigh2highlow(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[0]; + return b; +} + +__device__ __half2 __lows2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ __half __short2half_rd(short int i) { + return (__half)i; +} + +__device__ __half __short2half_rn(short int i) { + return (__half)i; +} + +__device__ __half __short2half_ru(short int i) { + return (__half)i; +} + +__device__ __half __short2half_rz(short int i) { + return (__half)i; +} + +__device__ __half __uint2half_rd(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_rn(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_ru(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_rz(unsigned int i) { + return (__half)i; +} + +__device__ __half __ull2half_rd(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_rn(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_ru(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_rz(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rd(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rn(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_ru(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rz(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort_as_half(const unsigned short int i) { + hipHalfHolder hH; + hH.s = i; + return hH.h; +} + + +/* +Soft Implementation. Use it for backup. +*/ + static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; @@ -35,6 +542,8 @@ typedef struct{ }; } struct_float; +#if __clang_major__ == 3 + static __device__ float cvt_half_to_float(__half a){ struct_float ret = {0}; if(a.x == 0){ @@ -64,44 +573,44 @@ static __device__ __half cvt_float_to_half(float b){ } -__device__ __half __hadd(const __half a, const __half b){ +__device__ __half __soft_hadd(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)+cvt_half_to_float(b)); } -__device__ __half __hadd_sat(const __half a, const __half b){ +__device__ __half __soft_hadd_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) + cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hfma(const __half a, const __half b, const __half c){ +__device__ __half __soft_hfma(const __half a, const __half b, const __half c){ return cvt_float_to_half(fmaf(cvt_half_to_float(a), cvt_half_to_float(b), cvt_half_to_float(c))); } -__device__ __half __hfma_sat(const __half a, const __half b, const __half c){ +__device__ __half __soft_hfma_sat(const __half a, const __half b, const __half c){ float f = fmaf(cvt_half_to_float(a), cvt_half_to_float(b), cvt_half_to_float(c)); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hmul(const __half a, const __half b){ +__device__ __half __soft_hmul(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)*cvt_half_to_float(b)); } -__device__ __half __hmul_sat(const __half a, const __half b){ +__device__ __half __soft_hmul_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) * cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hneq(const __half a){ +__device__ __half __soft_hneq(const __half a){ __half ret = {a.x}; ret.x ^= 1 << 15; return ret; } -__device__ __half __hsub(const __half a, const __half b){ +__device__ __half __soft_hsub(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)-cvt_half_to_float(b)); } -__device__ __half __hsub_sat(const __half a, const __half b){ +__device__ __half __soft_hsub_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) - cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } @@ -111,66 +620,66 @@ __device__ __half __hsub_sat(const __half a, const __half b){ Half2 Arithmetic Instructions */ -__device__ __half2 __hadd2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hadd2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hadd(a.p, b.p); - ret.q = __hadd(a.q, b.q); + ret.p[1] = __soft_hadd(a.p[1], b.p[1]); + ret.p[0] = __soft_hadd(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hadd2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hadd2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hadd_sat(a.p, b.p); - ret.q = __hadd_sat(a.q, b.q); + ret.p[1] = __soft_hadd_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hadd_sat(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hfma2(const __half2 a, const __half2 b, const __half2 c){ +__device__ __half2 __soft_hfma2(const __half2 a, const __half2 b, const __half2 c){ __half2 ret; - ret.p = __hfma(a.p, b.p, c.p); - ret.q = __hfma(a.q, b.q, c.q); + ret.p[1] = __soft_hfma(a.p[1], b.p[1], c.p[1]); + ret.p[0] = __soft_hfma(a.p[0], b.p[0], c.p[0]); return ret; } -__device__ __half2 __hfma2_sat(const __half2 a, const __half2 b, const __half2 c){ +__device__ __half2 __soft_hfma2_sat(const __half2 a, const __half2 b, const __half2 c){ __half2 ret; - ret.p = __hfma_sat(a.p, b.p, c.p); - ret.q = __hfma_sat(a.q, b.q, c.q); + ret.p[1] = __soft_hfma_sat(a.p[1], b.p[1], c.p[1]); + ret.p[0] = __soft_hfma_sat(a.p[0], b.p[0], c.p[0]); return ret; } -__device__ __half2 __hmul2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hmul2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hmul(a.p, b.p); - ret.q = __hmul(a.q, b.q); + ret.p[1] = __soft_hmul(a.p[1], b.p[1]); + ret.p[0] = __soft_hmul(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hmul2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hmul2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hmul_sat(a.p, b.p); - ret.q = __hmul_sat(a.q, b.q); + ret.p[1] = __soft_hmul_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hmul_sat(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hneq2(const __half2 a){ +__device__ __half2 __soft_hneq2(const __half2 a){ __half2 ret; - ret.p = __hneq(a.p); - ret.q = __hneq(a.q); + ret.p[1] = __soft_hneq(a.p[1]); + ret.p[0] = __soft_hneq(a.p[0]); return ret; } -__device__ __half2 __hsub2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hsub2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hsub(a.p, b.p); - ret.q = __hsub(a.q, b.q); + ret.p[1] = __soft_hsub(a.p[1], b.p[1]); + ret.p[0] = __soft_hsub(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hsub2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hsub2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hsub_sat(a.p, b.p); - ret.q = __hsub_sat(a.q, b.q); + ret.p[1] = __soft_hsub_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hsub_sat(a.p[0], b.p[0]); return ret; } @@ -178,23 +687,23 @@ __device__ __half2 __hsub2_sat(const __half2 a, const __half2 b){ Half Cmps */ -__device__ bool __heq(const __half a, const __half b){ +__device__ bool __soft_heq(const __half a, const __half b){ return (a.x == b.x ? true:false); } -__device__ bool __hge(const __half a, const __half b){ +__device__ bool __soft_hge(const __half a, const __half b){ return (cvt_half_to_float(a) >= cvt_half_to_float(b)); } -__device__ bool __hgt(const __half a, const __half b){ +__device__ bool __soft_hgt(const __half a, const __half b){ return (cvt_half_to_float(a) > cvt_half_to_float(b)); } -__device__ bool __hisinf(const __half a){ +__device__ bool __soft_hisinf(const __half a){ return ((a.x == __half_neg_inf) ? -1 : (a.x == __half_pos_inf) ? 1 : 0); } -__device__ bool __hisnan(const __half a){ +__device__ bool __soft_hisnan(const __half a){ if(((a.x & __half_pos_inf) == a.x) || ((a.x & __half_neg_inf) == a.x)){ return true; }else{ @@ -202,15 +711,15 @@ __device__ bool __hisnan(const __half a){ } } -__device__ bool __hle(const __half a, const __half b){ +__device__ bool __soft_hle(const __half a, const __half b){ return (cvt_half_to_float(a) <= cvt_half_to_float(b)); } -__device__ bool __hlt(const __half a, const __half b){ +__device__ bool __soft_hlt(const __half a, const __half b){ return (cvt_half_to_float(a) < cvt_half_to_float(b)); } -__device__ bool __hne(const __half a, const __half b){ +__device__ bool __soft_hne(const __half a, const __half b){ return a.x == b.x ? false : true; } @@ -218,78 +727,78 @@ __device__ bool __hne(const __half a, const __half b){ Half2 Cmps */ -__device__ bool __hbeq2(const __half2 a, const __half2 b){ - return __heq(a.p, b.p) && __heq(a.q, b.q); +__device__ bool __soft_hbeq2(const __half2 a, const __half2 b){ + return __soft_heq(a.p[1], b.p[1]) && __soft_heq(a.p[0], b.p[0]); } -__device__ bool __hbge2(const __half2 a, const __half2 b){ - return __hge(a.p, b.p) && __hge(a.q, b.q); +__device__ bool __soft_hbge2(const __half2 a, const __half2 b){ + return __soft_hge(a.p[1], b.p[1]) && __soft_hge(a.p[0], b.p[0]); } -__device__ bool __hbgt2(const __half2 a, const __half2 b){ - return __hgt(a.p, b.p) && __hgt(a.q, b.q); +__device__ bool __soft_hbgt2(const __half2 a, const __half2 b){ + return __soft_hgt(a.p[1], b.p[1]) && __soft_hgt(a.p[0], b.p[0]); } -__device__ bool __hble2(const __half2 a, const __half2 b){ - return __hle(a.p, b.p) && __hle(a.q, b.q); +__device__ bool __soft_hble2(const __half2 a, const __half2 b){ + return __soft_hle(a.p[1], b.p[1]) && __soft_hle(a.p[0], b.p[0]); } -__device__ bool __hblt2(const __half2 a, const __half2 b){ - return __hlt(a.p, b.p) && __hlt(a.q, b.q); +__device__ bool __soft_hblt2(const __half2 a, const __half2 b){ + return __soft_hlt(a.p[1], b.p[1]) && __soft_hlt(a.p[0], b.p[0]); } -__device__ bool __hbne2(const __half2 a, const __half2 b){ - return __hne(a.p, b.p) && __hne(a.q, b.q); +__device__ bool __soft_hbne2(const __half2 a, const __half2 b){ + return __soft_hne(a.p[1], b.p[1]) && __soft_hne(a.p[0], b.p[0]); } -__device__ __half2 __heq2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_heq2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__heq(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__heq(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_heq(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_heq(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hge2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hge2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hge(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hge(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hge(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hge(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hgt2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hgt2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hgt(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hgt(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hgt(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hgt(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hisnan2(const __half2 a){ +__device__ __half2 __soft_hisnan2(const __half2 a){ __half2 ret = {0}; - ret.p = __hisnan(a.p) ? __half_value_one_float : __half_value_zero_float; - ret.q = __hisnan(a.q) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = __soft_hisnan(a.p[1]) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = __soft_hisnan(a.p[0]) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hle2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hle2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hle(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hle(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hle(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hle(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hlt2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hlt2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hlt(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hlt(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hlt(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hlt(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hne2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hne2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hne(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hne(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hne(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hne(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } @@ -297,78 +806,82 @@ __device__ __half2 __hne2(const __half2 a, const __half2 b){ Half Cnvs and Data Mvmnt */ -__device__ __half2 __float22half2_rn(const float2 a){ +__device__ __half2 __soft_float22half2_rn(const float2 a){ __half2 ret = {0}; - ret.p = cvt_float_to_half(a.x); - ret.q = cvt_float_to_half(a.y); + ret.p[1] = cvt_float_to_half(a.x); + ret.p[0] = cvt_float_to_half(a.y); return ret; } -__device__ __half __float2half(const float a){ +__device__ __half __soft_float2half(const float a){ return cvt_float_to_half(a); } -__device__ __half2 __float2half2_rn(const float a){ +__device__ __half2 __soft_float2half2_rn(const float a){ __half ret = cvt_float_to_half(a); return {ret, ret}; } -__device__ __half2 __floats2half2_rn(const float a, const float b){ +__device__ __half2 __soft_floats2half2_rn(const float a, const float b){ return {cvt_float_to_half(a), cvt_float_to_half(b)}; } -__device__ float2 __half22float2(const __half2 a){ - return {cvt_half_to_float(a.p), cvt_half_to_float(a.q)}; +__device__ float2 __soft_half22float2(const __half2 a){ + return {cvt_half_to_float(a.p[1]), cvt_half_to_float(a.p[0])}; } -__device__ float __half2float(const __half a){ +__device__ float __soft_half2float(const __half a){ return cvt_half_to_float(a); } -__device__ __half2 __half2half2(const __half a){ +__device__ __half2 __soft_half2half2(const __half a){ return {a,a}; } -__device__ __half2 __halves2half2(const __half a, const __half b){ +__device__ __half2 __soft_halves2half2(const __half a, const __half b){ return {a,b}; } -__device__ float __high2float(const __half2 a){ - return cvt_half_to_float(a.p); +__device__ float __soft_high2float(const __half2 a){ + return cvt_half_to_float(a.p[1]); } -__device__ __half __high2half(const __half2 a){ - return a.p; +__device__ __half __soft_high2half(const __half2 a){ + return a.p[1]; } -__device__ __half2 __high2half2(const __half2 a){ - return {a.p, a.p}; +__device__ __half2 __soft_high2half2(const __half2 a){ + return {a.p[1], a.p[1]}; } -__device__ __half2 __highs2half2(const __half2 a, const __half2 b){ - return {a.p, b.p}; +__device__ __half2 __soft_highs2half2(const __half2 a, const __half2 b){ + return {a.p[1], b.p[1]}; } -__device__ float __low2float(const __half2 a){ - return cvt_half_to_float(a.q); +__device__ float __soft_low2float(const __half2 a){ + return cvt_half_to_float(a.p[0]); } -__device__ __half __low2half(const __half2 a){ - return a.q; +__device__ __half __soft_low2half(const __half2 a){ + return a.p[0]; } -__device__ __half2 __low2half2(const __half2 a){ - return {a.q, a.q}; +__device__ __half2 __soft_low2half2(const __half2 a){ + return {a.p[0], a.p[0]}; } -__device__ __half2 __lows2half2(const __half2 a, const __half2 b){ - return {a.q, b.q}; +__device__ __half2 __soft_lows2half2(const __half2 a, const __half2 b){ + return {a.p[0], b.p[0]}; } -__device__ __half2 __lowhigh2highlow(const __half2 a){ - return {a.q, a.p}; +__device__ __half2 __soft_lowhigh2highlow(const __half2 a){ + return {a.p[0], a.p[1]}; } -__device__ __half2 __low2half2(const __half2 a, const __half2 b){ - return {a.q, b.q}; +__device__ __half2 __soft_low2half2(const __half2 a, const __half2 b){ + return {a.p[0], b.p[0]}; } + + + +#endif diff --git a/projects/hip/src/hip_hc.ll b/projects/hip/src/hip_hc.ll new file mode 100644 index 0000000000..aba9205912 --- /dev/null +++ b/projects/hip/src/hip_hc.ll @@ -0,0 +1,30 @@ +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5: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" +target triple = "amdgcn--amdhsa" + +define i32 @__hip_hc_ir_mul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_i32_i24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_u32_u24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_mulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_i32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_u32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_sad_u32 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + ret i32 %1 +} + +attributes #1 = { alwaysinline nounwind } + diff --git a/projects/hip/src/hip_hc_gfx803.ll b/projects/hip/src/hip_hc_gfx803.ll new file mode 100644 index 0000000000..0080fc7d81 --- /dev/null +++ b/projects/hip/src/hip_hc_gfx803.ll @@ -0,0 +1,90 @@ +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5: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" +target triple = "amdgcn--amdhsa" + + +define i32 @__hip_hc_ir_hadd2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_add_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_hfma2_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_mad_f16 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + tail call void asm sideeffect "v_mul_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + tail call void asm sideeffect "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %1, i32 %c) + ret i32 %1 +} + +define i32 @__hip_hc_ir_hmul2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_mul_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_hsub2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_sub_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_sub_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2ceil_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_ceil_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_ceil_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2cos_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_cos_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_cos_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2exp2_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_exp_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_exp_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2floor_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_floor_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_floor_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2log2_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_log_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_log_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2rcp_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_rcp_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_rcp_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2rsqrt_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_rsq_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_rsq_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2sin_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_sin_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_sin_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2sqrt_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_sqrt_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_sqrt_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_trunc_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_trunc_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 84794b02fb..71d947488d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -41,17 +41,21 @@ THE SOFTWARE. #include #include #include "hsa/hsa_ext_amd.h" -#include "libhsakmt/hsakmt.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" +#include "env.h" #ifndef USE_COPY_EXT_V2 #define USE_COPY_EXT_V2 1 #endif +#ifndef USE_ROCR_1_4 +#define USE_ROCR_1_4 1 +#endif + //================================================================================================= //Global variables: //================================================================================================= @@ -65,6 +69,8 @@ std::string HIP_LAUNCH_BLOCKING_KERNELS; std::vector g_hipLaunchBlockingKernels; int HIP_API_BLOCKING = 0; +int HIP_MAX_QUEUES = 0; + int HIP_PRINT_ENV = 0; int HIP_TRACE_API= 0; std::string HIP_TRACE_API_COLOR("green"); @@ -79,6 +85,7 @@ int HIP_NUM_KERNELS_INFLIGHT = 128; int HIP_WAIT_MODE = 0; int HIP_FORCE_P2P_HOST = 0; +int HIP_FAIL_SOC = 0; int HIP_DENY_PEER_ACCESS = 0; // Force async copies to actually use the synchronous copy interface. @@ -86,6 +93,12 @@ int HIP_FORCE_SYNC_COPY = 0; int HIP_COHERENT_HOST_ALLOC = 0; +// TODO - set to 0 once we resolve stability. +// USE_ HIP_SYNC_HOST_ALLOC +int HIP_SYNC_HOST_ALLOC = 1; + +int HCC_OPT_FLUSH = 0; + @@ -123,7 +136,7 @@ std::vector g_dbStopTriggers; thread_local hipError_t tls_lastHipError = hipSuccess; -thread_local ShortTid tls_shortTid; +thread_local TidInfo tls_tidInfo; @@ -133,8 +146,8 @@ thread_local ShortTid tls_shortTid; //================================================================================================= void recordApiTrace(std::string *fullStr, const std::string &apiStr) { - auto apiSeqNum = tls_shortTid.incApiSeqNum(); - auto tid = tls_shortTid.tid(); + auto apiSeqNum = tls_tidInfo.apiSeqNum(); + auto tid = tls_tidInfo.tid(); if ((tid < g_dbStartTriggers.size()) && (apiSeqNum >= g_dbStartTriggers[tid].nextTrigger())) { printf ("info: resume profiling at %lu\n", apiSeqNum); @@ -214,7 +227,7 @@ hipError_t ihipSynchronize(void) //================================================================================================= // ihipStream_t: //================================================================================================= -ShortTid::ShortTid() : +TidInfo::TidInfo() : _apiSeqNum(0) { _shortTid = g_lastShortTid.fetch_add(1); @@ -237,7 +250,7 @@ ihipStream_t::ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int _id(0), // will be set by add function. _flags(flags), _ctx(ctx), - _criticalData(av) + _criticalData(this, av) { unsigned schedBits = ctx->_ctxFlags & hipDeviceScheduleMask; @@ -250,7 +263,6 @@ ihipStream_t::ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int }; - tprintf(DB_SYNC, " streamCreate: stream=%p\n", this); }; @@ -260,12 +272,38 @@ ihipStream_t::~ihipStream_t() } +inline void ihipStream_t::ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit) +{ + if (HIP_MAX_QUEUES && !streamCrit->_hasQueue) { + + // To avoid deadlock, we have to release the stream lock before acquiring context lock. + // Else we can get hung if another thread has the context lock is trying to get lock for this stream. + // We lock it again below. + streamCrit->munlock(); + + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_CtxCrit_t ctxCrit(this->_ctx->criticalData()); + // TODO + auto needyCritPtr = this->_criticalData.mlock(); + + // Second test to ensure we still need to steal the queue - another thread may have + // snuck in here and already solved the issue. + if (!needyCritPtr->_hasQueue) { + needyCritPtr->_av = this->_ctx->stealActiveQueue(ctxCrit, this); + } + + streamCrit->_hasQueue = true; + } + assert(streamCrit->_hasQueue); +} + + //Wait for all kernel and data copy commands in this stream to complete. //This signature should be used in routines that already have locked the stream mutex -void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty) +void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit) { - if (! assertQueueEmpty) { - tprintf (DB_SYNC, "stream %p wait for queue-empty..\n", this); + if (crit->_hasQueue) { + tprintf (DB_SYNC, "%s wait for queue-empty..\n", ToString(this).c_str()); hc::hcWaitMode waitMode = hc::hcWaitModeActive; if (_scheduleMode == Auto) { @@ -289,6 +327,8 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty } crit->_av.wait(waitMode); + } else { + tprintf (DB_SYNC, "%s wait for queue empty (done since stream has no physical queue).\n", ToString(this).c_str()); } crit->_kernelCnt = 0; @@ -296,19 +336,22 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty //--- //Wait for all kernel and data copy commands in this stream to complete. -void ihipStream_t::locked_wait(bool assertQueueEmpty) +void ihipStream_t::locked_wait() { LockedAccessor_StreamCrit_t crit(_criticalData); - wait(crit, assertQueueEmpty); + wait(crit); }; // Causes current stream to wait for specified event to complete: +// Note this does not require any kind of host serialization. void ihipStream_t::locked_waitEvent(hipEvent_t event) { LockedAccessor_StreamCrit_t crit(_criticalData); + this->ensureHaveQueue(crit); + crit->_av.create_blocking_marker(event->_marker); } @@ -319,6 +362,7 @@ void ihipStream_t::locked_recordEvent(hipEvent_t event) // Lock the stream to prevent simultaneous access LockedAccessor_StreamCrit_t crit(_criticalData); + this->ensureHaveQueue(crit); event->_marker = crit->_av.create_marker(); } @@ -349,13 +393,17 @@ ihipCtx_t * ihipStream_t::getCtx() const // Lock the stream to prevent other threads from intervening. LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand() { + LockedAccessor_StreamCrit_t crit(_criticalData, false/*no unlock at destruction*/); if(crit->_kernelCnt > HIP_NUM_KERNELS_INFLIGHT){ this->wait(crit); crit->_kernelCnt = 0; } - crit->_kernelCnt++; + + this->ensureHaveQueue(crit); + + return crit; } @@ -388,56 +436,6 @@ void ihipStream_t::lockclose_postKernelCommand(const char * kernelName, hc::acce - -#if USE_DISPATCH_HSA_KERNEL==0 -// Precursor: the stream is already locked,specifically so this routine can enqueue work into the specified av. -void ihipStream_t::launchModuleKernel( - hc::accelerator_view av, - hsa_signal_t signal, - uint32_t blockDimX, - uint32_t blockDimY, - uint32_t blockDimZ, - uint32_t gridDimX, - uint32_t gridDimY, - uint32_t gridDimZ, - uint32_t groupSegmentSize, - uint32_t privateSegmentSize, - void *kernarg, - size_t kernSize, - uint64_t kernel){ - hsa_status_t status; - hsa_queue_t *Queue = (hsa_queue_t*)av.get_hsa_queue(); - const uint32_t queue_mask = Queue->size-1; - uint32_t packet_index = hsa_queue_load_write_index_relaxed(Queue); - hsa_kernel_dispatch_packet_t *dispatch_packet = &(((hsa_kernel_dispatch_packet_t*)(Queue->base_address))[packet_index & queue_mask]); - - dispatch_packet->completion_signal = signal; - dispatch_packet->workgroup_size_x = blockDimX; - dispatch_packet->workgroup_size_y = blockDimY; - dispatch_packet->workgroup_size_z = blockDimZ; - dispatch_packet->grid_size_x = blockDimX * gridDimX; - dispatch_packet->grid_size_y = blockDimY * gridDimY; - dispatch_packet->grid_size_z = blockDimZ * gridDimZ; - dispatch_packet->group_segment_size = groupSegmentSize; - dispatch_packet->private_segment_size = privateSegmentSize; - dispatch_packet->kernarg_address = kernarg; - dispatch_packet->kernel_object = kernel; - uint16_t header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | - (1 << HSA_PACKET_HEADER_BARRIER) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); - - uint16_t setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; - uint32_t header32 = header | (setup << 16); - - __atomic_store_n((uint32_t*)(dispatch_packet), header32, __ATOMIC_RELEASE); - - hsa_queue_store_write_index_relaxed(Queue, packet_index + 1); - hsa_signal_store_relaxed(Queue->doorbell_signal, packet_index); -} -#endif - - //============================================================================= // Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. // The packed _peerAgents can efficiently be used on each memory allocation. @@ -521,7 +519,16 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) { stream->_id = _streams.size(); _streams.push_back(stream); + tprintf(DB_SYNC, " addStream: %s\n", ToString(stream).c_str()); } + +template<> +void ihipDeviceCriticalBase_t::addContext(ihipCtx_t *ctx) +{ + _ctxs.push_back(ctx); + tprintf(DB_SYNC, " addContext: %s\n", ToString(ctx).c_str()); +} + //============================================================================= //================================================================================================= @@ -529,7 +536,9 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) //================================================================================================= ihipDevice_t::ihipDevice_t(unsigned deviceId, unsigned deviceCnt, hc::accelerator &acc) : _deviceId(deviceId), - _acc(acc) + _acc(acc), + _state(0), + _criticalData(this) { hsa_agent_t *agent = static_cast (acc.get_hsa_agent()); if (agent) { @@ -556,7 +565,49 @@ ihipDevice_t::~ihipDevice_t() _primaryCtx = NULL; } +void ihipDevice_t::locked_removeContext(ihipCtx_t *c) +{ + LockedAccessor_DeviceCrit_t crit(_criticalData); + crit->ctxs().remove(c); + tprintf(DB_SYNC, " locked_removeContext: %s\n", ToString(c).c_str()); +} + + +void ihipDevice_t::locked_reset() +{ + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_DeviceCrit_t crit(_criticalData); + + + //--- + //Wait for pending activity to complete? TODO - check if this is required behavior: + tprintf(DB_SYNC, "locked_reset waiting for activity to complete.\n"); + + // Reset and remove streams: + // Delete all created streams including the default one. + for (auto ctxI=crit->const_ctxs().begin(); ctxI!=crit->const_ctxs().end(); ctxI++) { + ihipCtx_t *ctx = *ctxI; + (*ctxI)->locked_reset(); + tprintf(DB_SYNC, " ctx cleanup %s\n", ToString(ctx).c_str()); + + delete ctx; + } + // Clear the list. + crit->ctxs().clear(); + + + //reset _primaryCtx + _primaryCtx->locked_reset(); + tprintf(DB_SYNC, " _primaryCtx cleanup %s\n", ToString(_primaryCtx).c_str()); + // Reset and release all memory stored in the tracker: + // Reset will remove peer mapping so don't need to do this explicitly. + // FIXME - This is clearly a non-const action! Is this a context reset or a device reset - maybe should reference count? + + _state = 0; + am_memtracker_reset(_acc); + +}; #define ErrorCheck(x) error_check(x, __LINE__, __FILE__) @@ -707,11 +758,24 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) prop->isMultiGpuBoard = 0 ? gpuAgentsCount < 2 : 1; // Get agent name -#if HIP_USE_PRODUCT_NAME + err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, &(prop->name)); -#else - err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &(prop->name)); -#endif + char archName[256]; + err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &archName); + + if(strcmp(archName,"gfx701")==0){ + prop->gcnArch = 701; + } + if(strcmp(archName,"gfx801")==0){ + prop->gcnArch = 801; + } + if(strcmp(archName,"gfx802")==0){ + prop->gcnArch = 802; + } + if(strcmp(archName,"gfx803")==0){ + prop->gcnArch = 803; + } + DeviceErrorCheck(err); // Get agent node @@ -783,13 +847,14 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) _isLargeBar = _acc.has_cpu_accessible_am(); // Get Max Threads Per Multiprocessor - - HsaNodeProperties node_prop = {0}; - if(HSAKMT_STATUS_SUCCESS == hsaKmtGetNodeProperties(node, &node_prop)) { - uint32_t waves_per_cu = node_prop.MaxWavesPerSIMD; - uint32_t simd_per_cu = node_prop.NumSIMDPerCU; - prop-> maxThreadsPerMultiProcessor = prop->warpSize*waves_per_cu*simd_per_cu; - } + uint32_t max_waves_per_cu; +#if USE_ROCR_1_4 + err = hsa_agent_get_info(_hsaAgent,(hsa_agent_info_t) HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU, &max_waves_per_cu); +#else + max_waves_per_cu = 10; +#endif + DeviceErrorCheck(err); + prop-> maxThreadsPerMultiProcessor = prop->warpSize*max_waves_per_cu; // Get memory properties err = hsa_agent_iterate_regions(_hsaAgent, get_region_info, prop); @@ -857,11 +922,17 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) ihipCtx_t::ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags) : _ctxFlags(flags), _device(device), - _criticalData(deviceCnt) + _criticalData(this, deviceCnt) { - locked_reset(); + //locked_reset(); + LockedAccessor_CtxCrit_t crit(_criticalData); + _defaultStream = new ihipStream_t(this, getDevice()->_acc.get_default_view(), hipStreamDefault); + crit->addStream(_defaultStream); - tprintf(DB_SYNC, "created ctx with defaultStream=%p\n", _defaultStream); + + // Reset peer list to just me: + crit->resetPeerWatchers(this); + tprintf(DB_SYNC, "created ctx with defaultStream=%p (%s)\n", _defaultStream, ToString(_defaultStream).c_str()); }; @@ -891,7 +962,7 @@ void ihipCtx_t::locked_reset() for (auto streamI=crit->const_streams().begin(); streamI!=crit->const_streams().end(); streamI++) { ihipStream_t *stream = *streamI; (*streamI)->locked_wait(); - tprintf(DB_SYNC, " delete stream=%p\n", stream); + tprintf(DB_SYNC, " delete %s\n", ToString(stream).c_str()); delete stream; } @@ -903,7 +974,7 @@ void ihipCtx_t::locked_reset() _defaultStream = new ihipStream_t(this, getDevice()->_acc.get_default_view(), hipStreamDefault); crit->addStream(_defaultStream); - +#if 0 // Reset peer list to just me: crit->resetPeerWatchers(this); @@ -911,8 +982,9 @@ void ihipCtx_t::locked_reset() // Reset will remove peer mapping so don't need to do this explicitly. // FIXME - This is clearly a non-const action! Is this a context reset or a device reset - maybe should reference count? ihipDevice_t *device = getWriteableDevice(); + device->_state = 0; am_memtracker_reset(device->_acc); - +#endif }; @@ -924,6 +996,56 @@ std::string ihipCtx_t::toString() const return ss.str(); }; + +hc::accelerator_view +ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream) +{ + + // TODO - review handling if queue can't be found. + while (1) { + + for (auto iter=ctxCrit->streams().begin(); iter != ctxCrit->streams().end(); iter++) { + if (*iter != needyStream) { + auto victimCritPtr = (*iter)->_criticalData.mtry_lock(); + if (victimCritPtr) { + // try-lock succeeded: + if (victimCritPtr->_hasQueue && (victimCritPtr->_kernelCnt == 0)) { + + victimCritPtr->_hasQueue = false; + + tprintf(DB_SYNC, " stealActiveQueue from victim:%s to needy:%s\n", + ToString(*iter).c_str(), ToString(needyStream).c_str()); + + hc::accelerator_view av = victimCritPtr->_av; + + // TODO - cleanup to remove forced setting to N + uint64_t *p = (uint64_t*)(&victimCritPtr->_av); + *p = 0; // damage the victim av so attempt to use it will fault. + + (*iter)->_criticalData.munlock(); + return av; + } + (*iter)->_criticalData.munlock(); + } + } + } + } +} + + +hc::accelerator_view +ihipCtx_t::createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit) +{ + if (HIP_MAX_QUEUES && (ctxCrit->streams().size() >= HIP_MAX_QUEUES)) { + // Steal a queue from an existing stream: + hc::accelerator_view av = this->stealActiveQueue (ctxCrit, nullptr); + return av; + } else { + // Create a new view + return getWriteableDevice()->_acc.create_view(); + } +} + //---- @@ -965,13 +1087,6 @@ void ihipCtx_t::locked_syncDefaultStream(bool waitOnSelf) } } -//--- -void ihipCtx_t::locked_addStream(ihipStream_t *s) -{ - LockedAccessor_CtxCrit_t crit(_criticalData); - - crit->addStream(s); -} //--- void ihipCtx_t::locked_removeStream(ihipStream_t *s) @@ -995,166 +1110,6 @@ void ihipCtx_t::locked_waitAllStreams() } - -//--- -// Read environment variables. -void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - // Default is set when variable is initialized (at top of this file), so only override if we find - // an environment variable. - if (env) { - long int v = strtol(env, NULL, 0); - *var_ptr = (int) (v); - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %2d : %s\n", var_name1, *var_ptr, description); - } -} - - -void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - if (env) { - *static_cast(var_ptr) = env; - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %s : %s\n", var_name1, var_ptr->c_str(), description); - } -} - - -void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - std::string var_string = "0"; - if (env) { - var_string = setterCallback(var_ptr, env); - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %s : %s\n", var_name1, var_string.c_str(), description); - } -} - - -#if defined (DEBUG) - -#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback);\ - }; - -#else - -#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if (_build == release) {\ - ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; - -#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if (_build == release) {\ - ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ - if (_build == release) {\ - ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback);\ - }; - -#endif - - -static void tokenize(const std::string &s, char delim, std::vector *tokens) -{ - std::stringstream ss; - ss.str(s); - std::string item; - while (getline(ss, item, delim)) { - item.erase (std::remove (item.begin(), item.end(), ' '), item.end()); // remove whitespace. - tokens->push_back(item); - } -} - -static void trim(std::string *s) -{ - // trim whitespace from beginning and end: - const char *t = "\t\n\r\f\v"; - s->erase(0, s->find_first_not_of(t)); - s->erase(s->find_last_not_of(t)+1); -} - -static void ltrim(std::string *s) -{ - // trim whitespace from beginning - const char *t = "\t\n\r\f\v"; - s->erase(0, s->find_first_not_of(t)); -} - - -// TODO - change last arg to pointer. -void parseTrigger(std::string triggerString, std::vector &profTriggers ) -{ - std::vector tidApiTokens; - tokenize(std::string(triggerString), ',', &tidApiTokens); - for (auto t=tidApiTokens.begin(); t != tidApiTokens.end(); t++) { - std::vector oneToken; - //std::cout << "token=" << *t << "\n"; - tokenize(std::string(*t), '.', &oneToken); - int tid = 1; - uint64_t apiTrigger = 0; - if (oneToken.size() == 1) { - // the case with just apiNum - apiTrigger = std::strtoull(oneToken[0].c_str(), nullptr, 0); - } else if (oneToken.size() == 2) { - // the case with tid.apiNum - tid = std::strtoul(oneToken[0].c_str(), nullptr, 0); - apiTrigger = std::strtoull(oneToken[1].c_str(), nullptr, 0); - } else { - throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? - } - - if (tid > 10000) { - throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? - } else { - profTriggers.resize(tid+1); - //std::cout << "tid:" << tid << " add: " << apiTrigger << "\n"; - profTriggers[tid].add(apiTrigger); - } - } - - - for (int tid=1; tid &profTriggers ) { + std::vector tidApiTokens; + tokenize(std::string(triggerString), ',', &tidApiTokens); + for (auto t=tidApiTokens.begin(); t != tidApiTokens.end(); t++) { + std::vector oneToken; + //std::cout << "token=" << *t << "\n"; + tokenize(std::string(*t), '.', &oneToken); + int tid = 1; + uint64_t apiTrigger = 0; + if (oneToken.size() == 1) { + // the case with just apiNum + apiTrigger = std::strtoull(oneToken[0].c_str(), nullptr, 0); + } else if (oneToken.size() == 2) { + // the case with tid.apiNum + tid = std::strtoul(oneToken[0].c_str(), nullptr, 0); + apiTrigger = std::strtoull(oneToken[1].c_str(), nullptr, 0); + } else { + throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? + } -#if COMPILE_HIP_ATP_MARKER - amdtInitializeActivityLogger(); - amdtScopedMarker("ihipInit", "HIP", NULL); -#endif + if (tid > 10000) { + throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? + } else { + profTriggers.resize(tid+1); + //std::cout << "tid:" << tid << " add: " << apiTrigger << "\n"; + profTriggers[tid].add(apiTrigger); + } + } + + + for (int tid=1; tid_flags & hipStreamNonBlocking)) { - tprintf(DB_SYNC, "stream %p wait default stream\n", stream); + tprintf(DB_SYNC, "%s wait default stream\n", ToString(stream).c_str()); stream->getCtx()->_defaultStream->locked_wait(); } @@ -1423,11 +1431,11 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t stream) void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, const hipStream_t stream) { - if (HIP_PROFILE_API || (COMPILE_HIP_DB && HIP_TRACE_API)) { + if ((HIP_TRACE_API & (1<grid_dim << " groupDim:" << lp->group_dim @@ -1548,7 +1556,6 @@ void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launc MARKER_END(); } - //================================================================================================= // HIP API Implementation // @@ -1599,6 +1606,7 @@ const char *ihipErrorString(hipError_t hip_error) case hipErrorSharedObjectSymbolNotFound : return "hipErrorSharedObjectSymbolNotFound"; case hipErrorSharedObjectInitFailed : return "hipErrorSharedObjectInitFailed"; case hipErrorOperatingSystem : return "hipErrorOperatingSystem"; + case hipErrorSetOnActiveProcess : return "hipErrorSetOnActiveProcess"; case hipErrorInvalidHandle : return "hipErrorInvalidHandle"; case hipErrorNotFound : return "hipErrorNotFound"; case hipErrorIllegalAddress : return "hipErrorIllegalAddress"; @@ -1633,23 +1641,6 @@ const char *ihipErrorString(hipError_t hip_error) }; -void ihipSetTs(hipEvent_t e) -{ - ihipEvent_t *eh = e; - if (eh->_state == hipEventStatusRecorded) { - // already recorded, done: - return; - } else { - // TODO - use completion-future functions to obtain ticks and timestamps: - hsa_signal_t *sig = static_cast (eh->_marker.get_native_handle()); - if (sig) { - if (hsa_signal_load_acquire(*sig) == 0) { - eh->_timestamp = eh->_marker.get_end_tick(); - eh->_state = hipEventStatusRecorded; - } - } - } -} // Returns true if copyEngineCtx can see the memory allocated on dstCtx and srcCtx. @@ -1774,21 +1765,100 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, if (HIP_FORCE_P2P_HOST & 0x1) { *forceUnpinnedCopy = true; - tprintf (DB_COPY, "P2P. Copy engine (dev:%d agent=0x%lx) can see src and dst but HIP_FORCE_P2P_HOST=0, forcing copy through staging buffers.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + tprintf (DB_COPY, "Copy engine (dev:%d agent=0x%lx) can see src and dst but HIP_FORCE_P2P_HOST=0, forcing copy through staging buffers.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); } else { - tprintf (DB_COPY, "P2P. Copy engine (dev:%d agent=0x%lx) can see src and dst.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + tprintf (DB_COPY, "Copy engine (dev:%d agent=0x%lx) can see src and dst.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); } } else { *forceUnpinnedCopy = true; - tprintf (DB_COPY, "P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + tprintf (DB_COPY, "P2P: Copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); + if (HIP_FAIL_SOC & 0x2) { + fprintf (stderr, "HIP_FAIL_SOC: P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); + throw ihipException(hipErrorRuntimeOther); + } } } +void printPointerInfo(unsigned dbFlag, const char *tag, const void *ptr, const hc::AmPointerInfo &ptrInfo) +{ + tprintf (dbFlag, " %s=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d registered=%d\n", + tag, ptr, + ptrInfo._hostPointer, ptrInfo._devicePointer, ptrInfo._sizeBytes, + ptrInfo._appId, ptrInfo._sizeBytes != 0, ptrInfo._isInDeviceMem, !ptrInfo._isAmManaged); +} + + +// the pointer-info as returned by HC refers to the allocation +// This routine modifies the pointer-info so it appears to refer to the specific ptr and sizeBytes. +// TODO -remove this when HCC uses HSA pointer info functions directly. +void tailorPtrInfo(hc::AmPointerInfo *ptrInfo, const void * ptr, size_t sizeBytes) +{ + const char *ptrc = static_cast (ptr); + if (ptrInfo->_sizeBytes == 0) { + // invalid ptrInfo, don't modify + return; + } else if (ptrInfo->_isInDeviceMem) { + assert (ptrInfo->_devicePointer != nullptr); + std::ptrdiff_t diff = ptrc - static_cast (ptrInfo->_devicePointer); + + //TODO : assert-> runtime assert that only appears in debug mode + assert (diff >= 0); + assert (diff <= ptrInfo->_sizeBytes); + + ptrInfo->_devicePointer = const_cast (ptr); + + if (ptrInfo->_hostPointer != nullptr) { + ptrInfo->_hostPointer = static_cast(ptrInfo->_hostPointer) + diff; + } + + } else { + + assert (ptrInfo->_hostPointer != nullptr); + std::ptrdiff_t diff = ptrc - static_cast (ptrInfo->_hostPointer); + + //TODO : assert-> runtime assert that only appears in debug mode + assert (diff >= 0); + assert (diff <= ptrInfo->_sizeBytes); + + ptrInfo->_hostPointer = const_cast(ptr); + + if (ptrInfo->_devicePointer != nullptr) { + ptrInfo->_devicePointer = static_cast(ptrInfo->_devicePointer) + diff; + } + } + + assert (sizeBytes <= ptrInfo->_sizeBytes); + ptrInfo->_sizeBytes = sizeBytes; +}; + + +bool getTailoredPtrInfo(hc::AmPointerInfo *ptrInfo, const void * ptr, size_t sizeBytes) +{ + bool tracked = (hc::am_memtracker_getinfo(ptrInfo, ptr) == AM_SUCCESS); + + if (tracked) { + tailorPtrInfo(ptrInfo, ptr, sizeBytes); + } + + return tracked; +}; + + +// TODO : For registered and host memory, if the portable flag is set, we need to recognize that and perform appropriate copy operation. +// What can happen now is that Portable memory is mapped into multiple devices but Peer access is not enabled. i +// The peer detection logic doesn't see that the memory is already mapped and so tries to use an unpinned copy algorithm. If this is PinInPlace, then an error can occur. +// Need to track Portable flag correctly or use new RT functionality to query the peer status for the pointer. +// // TODO - remove kind parm from here or use it below? void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn) { @@ -1802,8 +1872,17 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, hc::accelerator acc; hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); - bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); - bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + bool dstTracked = getTailoredPtrInfo(&dstPtrInfo, dst, sizeBytes); + bool srcTracked = getTailoredPtrInfo(&srcPtrInfo, src, sizeBytes); + + + // Some code in HCC and in printPointerInfo uses _sizeBytes==0 as an indication ptr is not valid, so check it here: + if (!dstTracked) { + assert (dstPtrInfo._sizeBytes == 0); + } + if (!srcTracked) { + assert (srcPtrInfo._sizeBytes == 0); + } hc::hcCommandKind hcCopyDir; @@ -1818,13 +1897,10 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); - tprintf (DB_COPY, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, - dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); - tprintf (DB_COPY, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, - srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + printPointerInfo(DB_COPY, " dst", dst, dstPtrInfo); + printPointerInfo(DB_COPY, " src", src, srcPtrInfo); + this->ensureHaveQueue(crit); #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); @@ -1834,6 +1910,56 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } +void ihipStream_t::addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes) { + hc::AmPointerInfo ptrInfo(NULL, ptr, sizeBytes, acc, true, false); + hc::am_memtracker_add(ptr, ptrInfo); +} + +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, size_t offset, unsigned kind) +{ + if(kind == hipMemcpyHostToHost){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset, Kalmar::hcMemcpyHostToHost); + } + if(kind == hipMemcpyHostToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset); + } + if(kind == hipMemcpyDeviceToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset, Kalmar::hcMemcpyDeviceToDevice); + } + if(kind == hipMemcpyDeviceToHost){ + acc.memcpy_symbol((void*) src, (void*)dst, sizeBytes, offset, Kalmar::hcMemcpyDeviceToHost); + } +} + +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, size_t offset, unsigned kind) +{ + // TODO - review - this looks broken , should not be adding pointers to tracker dynamically: + if(kind == hipMemcpyHostToDevice) { + hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); + bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + if(srcTracked) { + addSymbolPtrToTracker(acc, dst, sizeBytes); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } else { + LockedAccessor_StreamCrit_t crit(_criticalData); + this->wait(crit); + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset); + } + } + if(kind == hipMemcpyDeviceToHost) { + hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); + bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); + if(dstTracked) { + addSymbolPtrToTracker(acc, src, sizeBytes); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } else { + LockedAccessor_StreamCrit_t crit(_criticalData); + this->wait(crit); + acc.memcpy_symbol((void*)src, (void*)dst, sizeBytes, offset, Kalmar::hcMemcpyDeviceToHost); + } + } +} + void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) { @@ -1862,8 +1988,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes hc::accelerator acc; hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); - bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); - bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + bool dstTracked = getTailoredPtrInfo(&dstPtrInfo, dst, sizeBytes); + bool srcTracked = getTailoredPtrInfo(&srcPtrInfo, src, sizeBytes); hc::hcCommandKind hcCopyDir; @@ -1875,12 +2001,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); - tprintf (DB_COPY, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, - dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); - tprintf (DB_COPY, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, - srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + printPointerInfo(DB_COPY, " dst", dst, dstPtrInfo); + printPointerInfo(DB_COPY, " src", src, srcPtrInfo); // "tracked" really indicates if the pointer's virtual address is available in the GPU address space. // If both pointers are not tracked, we need to fall back to a sync copy. @@ -1889,6 +2011,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes // Perform fast asynchronous copy - we know copyDevice != NULL based on check above try { + this->ensureHaveQueue(crit); + if (HIP_FORCE_SYNC_COPY) { #if USE_COPY_EXT_V2 crit->_av.copy_ext (src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, ©Device->getDevice()->_acc, forceUnpinnedCopy); @@ -1914,7 +2038,26 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes } } else { + if (HIP_FAIL_SOC & 0x1) { + fprintf (stderr, "HIP_FAIL_SOC failed, async_copy requested but could not be completed since src or dst not accesible to copy agent\n"); + fprintf (stderr, "copyASync copyDev:%d dst=%p (phys_dev:%d, isDevMem:%d) src=%p(phys_dev:%d, isDevMem:%d) sz=%zu dir=%s forceUnpinnedCopy=%d\n", + copyDevice ? copyDevice->getDeviceNum():-1, + dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, + src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, + sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); + fprintf (stderr, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", + dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, + dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); + fprintf (stderr, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", + src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, + srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + throw ihipException(hipErrorRuntimeOther); + } + // Perform slow synchronous copy: LockedAccessor_StreamCrit_t crit(_criticalData); + + this->ensureHaveQueue(crit); + #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); #else @@ -1972,6 +2115,7 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc) //--- +// Warning - with HIP_MAX_QUEUES!=0 there is no mechanism to prevent accelerator_view from being re-assigned... hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av) { HIP_INIT_API(stream, av); @@ -1981,7 +2125,7 @@ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **a stream = device->_defaultStream; } - *av = stream->locked_getAv(); + *av = stream->locked_getAv(); // TODO - review. hipError_t err = hipSuccess; return ihipLogStatus(err); diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc_internal.h similarity index 75% rename from projects/hip/src/hip_hcc.h rename to projects/hip/src/hip_hcc_internal.h index 82290bc489..9c17c6e98c 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,22 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_H -#define HIP_HCC_H +#ifndef HIP_SRC_HIP_HCC_INTERNAL_H +#define HIP_SRC_HIP_HCC_INTERNAL_H #include #include #include "hsa/hsa_ext_amd.h" + +#include "hip/hip_runtime.h" #include "hip_util.h" +#include "env.h" #if defined(__HCC__) && (__hcc_workweek__ < 16354) #error("This version of HIP requires a newer version of HCC."); #endif -#define USE_DISPATCH_HSA_KERNEL 1 -// - +#define USE_IPC 1 //--- // Environment variables: @@ -63,14 +64,17 @@ extern int HIP_COHERENT_HOST_ALLOC; //--- // Chicken bits for disabling functionality to work around potential issues: -extern int HIP_DISABLE_HW_KERNEL_DEP; +extern int HIP_SYNC_HOST_ALLOC; + +// TODO - remove when this is standard behavior. +extern int HCC_OPT_FLUSH; // Class to assign a short TID to each new thread, for HIP debugging purposes. -class ShortTid { +class TidInfo { public: - ShortTid() ; + TidInfo() ; int tid() const { return _shortTid; }; uint64_t incApiSeqNum() { return ++_apiSeqNum; }; @@ -107,7 +111,7 @@ private: //--- //Extern tls extern thread_local hipError_t tls_lastHipError; -extern thread_local ShortTid tls_shortTid; +extern thread_local TidInfo tls_tidInfo; extern std::vector g_dbStartTriggers; extern std::vector g_dbStopTriggers; @@ -139,6 +143,8 @@ extern const char *API_COLOR_END; #define CTX_THREAD_SAFE 1 +#define DEVICE_THREAD_SAFE 1 + // Compile debug trace mode - this prints debug messages to stderr when env var HIP_DB is set. // May be set to 0 to remove debug if checks - possible code size and performance difference? @@ -163,7 +169,7 @@ extern const char *API_COLOR_END; // Compile support for trace markers that are displayed on CodeXL GUI at start/stop of each function boundary. -// TODO - currently we print the trace message at the beginning. if we waited, we could also include return codes, and any values returned +// TODO - currently we print the trace message at the beginning. if we waited, we could also tls_tidInfo return codes, and any values returned // through ptr-to-args (ie the pointers allocated by hipMalloc). #if COMPILE_HIP_ATP_MARKER #include "CXLActivityLogger.h" @@ -180,51 +186,11 @@ extern const char *API_COLOR_END; #endif -extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); - -#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) -#define API_TRACE(...)\ -{\ - if (HIP_PROFILE_API || (COMPILE_HIP_DB && HIP_TRACE_API)) {\ - std::string apiStr = std::string(__func__) + " (" + ToString(__VA_ARGS__) + ')';\ - std::string fullStr;\ - recordApiTrace(&fullStr, apiStr);\ - if (HIP_PROFILE_API == 0x1) {MARKER_BEGIN(__func__, "HIP") }\ - else if (HIP_PROFILE_API == 0x2) {MARKER_BEGIN(fullStr.c_str(), "HIP"); }\ - }\ -} -#else -// Swallow API_TRACE -#define API_TRACE(...) -#endif - - -// Just initialize the HIP runtime, but don't log any trace information. -#define HIP_INIT()\ - std::call_once(hip_initialized, ihipInit);\ - ihipCtxStackUpdate(); - - -// This macro should be called at the beginning of every HIP API. -// It initialies the hip runtime (exactly once), and -// generate trace string that can be output to stderr or to ATP file. -#define HIP_INIT_API(...) \ - HIP_INIT()\ - API_TRACE(__VA_ARGS__); - -#define ihipLogStatus(hipStatus) \ - ({\ - hipError_t localHipStatus = hipStatus; /*local copy so hipStatus only evaluated once*/ \ - tls_lastHipError = localHipStatus;\ - \ - if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API) {\ - fprintf(stderr, " %ship-api tid:%d.%lu %-30s ret=%2d (%s)>>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_shortTid.tid(),tls_shortTid.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ - }\ - if (HIP_PROFILE_API) { MARKER_END(); }\ - localHipStatus;\ - }) - - +//--- +//HIP Trace modes +#define TRACE_ALL 0 // 0x1 +#define TRACE_CMD 1 // 0x2 +#define TRACE_MEM 2 // 0x4 //--- @@ -233,23 +199,23 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); #define DB_SYNC 1 /* 0x02 - trace synchronization pieces */ #define DB_MEM 2 /* 0x04 - trace memory allocation / deallocation */ #define DB_COPY 3 /* 0x08 - trace memory copy and peer commands. . */ -#define DB_SIGNAL 4 /* 0x10 - trace signal pool commands */ -#define DB_MAX_FLAG 5 +#define DB_MAX_FLAG 4 // When adding a new debug flag, also add to the char name table below. // +// struct DbName { const char *_color; const char *_shortName; }; +// This table must be kept in-sync with the defines above. static const DbName dbName [] = { {KGRN, "api"}, // not used, {KYEL, "sync"}, {KCYN, "mem"}, {KMAG, "copy"}, - {KRED, "signal"}, }; @@ -259,7 +225,7 @@ static const DbName dbName [] = if (HIP_DB & (1<<(trace_level))) {\ char msgStr[1000];\ snprintf(msgStr, 2000, __VA_ARGS__);\ - fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_shortTid.tid(), msgStr, KNRM); \ + fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \ }\ } #else @@ -270,6 +236,71 @@ static const DbName dbName [] = +//--- +extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); + +#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) +#define API_TRACE(forceTrace, ...)\ +{\ + tls_tidInfo.incApiSeqNum();\ + if (forceTrace || (HIP_PROFILE_API || (COMPILE_HIP_DB && (HIP_TRACE_API & (1<>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ + }\ + if (HIP_PROFILE_API) { MARKER_END(); }\ + localHipStatus;\ + }) + + + + + class ihipException : public std::exception { @@ -292,6 +323,34 @@ extern "C" { const hipStream_t hipStreamNull = 0x0; +/** + * HIP IPC Handle Size + */ +#define HIP_IPC_RESERVED_SIZE 24 +class ihipIpcMemHandle_t +{ +public: +#if USE_IPC + hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr +#endif + size_t psize; + char reserved[HIP_IPC_RESERVED_SIZE]; +}; + + +class ihipModule_t { +public: + hsa_executable_t executable; + hsa_code_object_t object; + std::string fileName; + void *ptr; + size_t size; + std::list funcTrack; + ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} +}; + + +//--- // Used to remove lock, for performance or stimulating bugs. class FakeMutex { @@ -314,6 +373,13 @@ typedef FakeMutex StreamMutex; typedef std::mutex CtxMutex; #else typedef FakeMutex CtxMutex; +#warning "Ctx thread-safe disabled" +#endif + +#if DEVICE_THREAD_SAFE +typedef std::mutex DeviceMutex; +#else +typedef FakeMutex DeviceMutex; #warning "Device thread-safe disabled" #endif @@ -330,21 +396,21 @@ public: _autoUnlock(autoUnlock) { - tprintf(DB_SYNC, "lock critical data %s.%p\n", typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "locking criticalData=%p for %s..\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.lock(); }; ~LockedAccessor() { if (_autoUnlock) { - tprintf(DB_SYNC, "auto-unlock critical data %s.%p\n",typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "auto-unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } } void unlock() { - tprintf(DB_SYNC, "unlock critical data %s.%p\n", typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } @@ -364,74 +430,21 @@ struct LockedBase { // Most uses should use the lock-accessor. void lock() { _mutex.lock(); } void unlock() { _mutex.unlock(); } + bool try_lock() { return _mutex.try_lock(); } MUTEX_TYPE _mutex; }; -/** - * HIP IPC Handle Size - */ -#define HIP_IPC_HANDLE_SIZE 64 -class ihipIpcMemHandle_t -{ -public: - hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr - char reserved[HIP_IPC_HANDLE_SIZE]; - size_t psize; -}; - -class ihipFunction_t{ -public: - ihipFunction_t(const char *name) { - size_t nameSz = strlen(name); - char *kernelName = (char*)malloc(nameSz); - strncpy(kernelName, name, nameSz); - _kernelName = kernelName; - }; - - ~ihipFunction_t() { - if (_kernelName) { - free((void*)_kernelName); - _kernelName = NULL; - }; - }; -public: - const char *_kernelName; - hsa_executable_symbol_t _kernelSymbol; - uint64_t _kernel; -}; - -class ihipModule_t { -public: - hsa_executable_t executable; - hsa_code_object_t object; - std::string fileName; - void *ptr; - size_t size; - - ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0), hipFunctionTable() {} - ~ihipModule_t() { - for (int i = 0; i < hipFunctionTable.size(); ++i) { - ihipFunction_t *func = hipFunctionTable[i]; - delete func; - } - hipFunctionTable.clear(); - } - - void registerFunction(ihipFunction_t* func) { - hipFunctionTable.push_back(func); - } -private: - std::vector hipFunctionTable; -}; template class ihipStreamCriticalBase_t : public LockedBase { public: - ihipStreamCriticalBase_t(hc::accelerator_view av) : + ihipStreamCriticalBase_t(ihipStream_t *parentStream, hc::accelerator_view av) : _kernelCnt(0), - _av(av) + _av(av), + _hasQueue(true), + _parent(parentStream) { }; @@ -440,10 +453,28 @@ public: ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; + void munlock() { + tprintf(DB_SYNC, "munlocking criticalData=%p for %s...\n", this, ToString(this->_parent).c_str()); + LockedBase::unlock(); + }; + + ihipStreamCriticalBase_t * mtry_lock() { + bool gotLock = LockedBase::try_lock() ; + tprintf(DB_SYNC, "mtry_locking=%d criticalData=%p for %s...\n", gotLock, this, ToString(this->_parent).c_str()); + return gotLock ? this: nullptr; + }; + public: - // TODO - remove _kernelCnt mechanism: + ihipStream_t * _parent; uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait(). + hc::accelerator_view _av; + + // True if the stream has an allocated queue (accelerato_view) for its use: + // Always true at ihipStream creation but queue may later be stolen. + // This acts as a valid bit for the _av. + bool _hasQueue; +private: }; @@ -451,13 +482,12 @@ public: // for the ihipCtx_t and then for the individual streams. The locks should not be acquired in reverse order // or deadlock may occur. In some cases, it may be possible to reduce the range where the locks must be held. // HIP routines should avoid acquiring and releasing the same lock during the execution of a single HIP API. +// Another option is to use try_lock in the innermost lock query. typedef ihipStreamCriticalBase_t ihipStreamCritical_t; typedef LockedAccessor LockedAccessor_StreamCrit_t; - - //--- // Internal stream structure. class ihipStream_t { @@ -465,15 +495,16 @@ public: enum ScheduleMode {Auto, Spin, Yield}; typedef uint64_t SeqNum_t ; + // TODOD -make av a reference to avoid shared_ptr overhead? ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int flags); ~ihipStream_t(); // kind is hipMemcpyKind void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); - - void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); //--- // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. @@ -481,7 +512,7 @@ public: void lockclose_postKernelCommand(const char *kernelName, hc::accelerator_view *av); - void locked_wait(bool assertQueueEmpty=false); + void locked_wait(); hc::accelerator_view* locked_getAv() { LockedAccessor_StreamCrit_t crit(_criticalData); return &(crit->_av); }; @@ -492,7 +523,7 @@ public: //--- // Use this if we already have the stream critical data mutex: - void wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty=false); + void wait(LockedAccessor_StreamCrit_t &crit); void launchModuleKernel(hc::accelerator_view av, hsa_signal_t signal, uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, @@ -507,6 +538,7 @@ public: const ihipDevice_t * getDevice() const; ihipCtx_t * getCtx() const; + void ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit); public: //--- @@ -528,11 +560,16 @@ private: bool canSeeMemory(const ihipCtx_t *thisCtx, const hc::AmPointerInfo *dstInfo, const hc::AmPointerInfo *srcInfo); + void addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes); -private: // Data +public: // TODO - move private // Critical Data - MUST be accessed through LockedAccessor_StreamCrit_t ihipStreamCritical_t _criticalData; +private: // Data + + std::mutex _hasQueueLock; + ihipCtx_t *_ctx; // parent context that owns this stream. // Friends: @@ -547,27 +584,78 @@ private: // Data //---- // Internal event structure: enum hipEventStatus_t { - hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. - hipEventStatusCreated = 1, - hipEventStatusRecording = 2, // event has been enqueued to record something. - hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. + hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. + hipEventStatusCreated = 1, + hipEventStatusRecording = 2, // event has been enqueued to record something. + hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. } ; +// TODO - rename to ihip type of some kind +enum ihipEventType_t { + hipEventTypeIndependent, + hipEventTypeStartCommand, + hipEventTypeStopCommand, +}; // internal hip event structure. -struct ihipEvent_t { - hipEventStatus_t _state; +class ihipEvent_t { +public: + ihipEvent_t(unsigned flags); + void attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType); + void setTimestamp(); + uint64_t timestamp() const { return _timestamp; } ; + ihipEventType_t type() const { return _type; }; + +public: + hipEventStatus_t _state; hipStream_t _stream; // Stream where the event is recorded, or NULL if all streams. unsigned _flags; hc::completion_future _marker; + +private: + ihipEventType_t _type; uint64_t _timestamp; // store timestamp, may be set on host or by marker. +friend hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream); } ; +//============================================================================= +//class ihipDeviceCriticalBase_t +template +class ihipDeviceCriticalBase_t : LockedBase +{ +public: + ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : + _parent(parentDevice) + { + }; + ~ihipDeviceCriticalBase_t() { + + } + + // Contexts: + void addContext(ihipCtx_t *ctx); + void removeContext(ihipCtx_t *ctx); + std::list &ctxs() { return _ctxs; }; + const std::list &const_ctxs() const { return _ctxs; }; + int getcount() {return _ctxCount;}; + friend class LockedAccessor; +private: + ihipDevice_t *_parent; + + //--- Context Tracker: + std::list< ihipCtx_t* > _ctxs; // contexts associated with this device across all threads. + + int _ctxCount; +}; + +typedef ihipDeviceCriticalBase_t ihipDeviceCritical_t; + +typedef LockedAccessor LockedAccessor_DeviceCrit_t; //---- // Properties of the HIP device. @@ -580,7 +668,9 @@ public: // Accessors: ihipCtx_t *getPrimaryCtx() const { return _primaryCtx; }; - + void locked_removeContext(ihipCtx_t *c); + void locked_reset(); + ihipDeviceCritical_t &criticalData() { return _criticalData; }; public: unsigned _deviceId; // device ID @@ -596,8 +686,12 @@ public: ihipCtx_t *_primaryCtx; + int _state; //1 if device is set otherwise 0 + private: hipError_t initProperties(hipDeviceProp_t* prop); +private: + ihipDeviceCritical_t _criticalData; }; //============================================================================= @@ -609,8 +703,9 @@ template class ihipCtxCriticalBase_t : LockedBase { public: - ihipCtxCriticalBase_t(unsigned deviceCnt) : - _peerCnt(0) + ihipCtxCriticalBase_t(ihipCtx_t *parentCtx, unsigned deviceCnt) : + _parent(parentCtx), + _peerCnt(0) { _peerAgents = new hsa_agent_t[deviceCnt]; }; @@ -629,6 +724,7 @@ public: const std::list &const_streams() const { return _streams; }; + // Peer Accessor classes: bool isPeerWatcher(const ihipCtx_t *peer); // returns True if peer has access to memory physically located on this device. bool addPeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); @@ -645,6 +741,8 @@ public: friend class LockedAccessor; private: + ihipCtx_t * _parent; + //--- Stream Tracker: std::list< ihipStream_t* > _streams; // streams associated with this device. @@ -679,16 +777,20 @@ public: // Functions: ~ihipCtx_t(); // Functions which read or write the critical data are named locked_. + // (might be better called "locking_" // ihipCtx_t does not use recursive locks so the ihip implementation must avoid calling a locked_ function from within a locked_ function. // External functions which call several locked_ functions will acquire and release the lock for each function. if this occurs in // performance-sensitive code we may want to refactor by adding non-locked functions and creating a new locked_ member function to call them all. - void locked_addStream(ihipStream_t *s); void locked_removeStream(ihipStream_t *s); void locked_reset(); void locked_waitAllStreams(); void locked_syncDefaultStream(bool waitOnSelf); - ihipCtxCritical_t &criticalData() { return _criticalData; }; // TODO, move private. Fix P2P. + // Will allocate a queue and assign it to the needyStream: + hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream); + hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); + + ihipCtxCritical_t &criticalData() { return _criticalData; }; const ihipDevice_t *getDevice() const { return _device; }; int getDeviceNum() const { return _device->_deviceId; }; @@ -733,19 +835,18 @@ extern ihipCtx_t *ihipGetTlsDefaultCtx(); extern void ihipSetTlsDefaultCtx(ihipCtx_t *ctx); extern hipError_t ihipSynchronize(void); extern void ihipCtxStackUpdate(); +extern hipError_t ihipDeviceSetState(); extern ihipDevice_t *ihipGetDevice(int); ihipCtx_t * ihipGetPrimaryCtx(unsigned deviceIndex); -extern void ihipSetTs(hipEvent_t e); - hipStream_t ihipSyncAndResolveStream(hipStream_t); // Stream printf functions: inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) { - os << "stream#"; + os << "stream:"; os << s.getDevice()->_deviceId;; os << '.'; os << s._id; diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll deleted file mode 100644 index d0e2a879a3..0000000000 --- a/projects/hip/src/hip_ir.ll +++ /dev/null @@ -1,37 +0,0 @@ -target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5: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" -target triple = "amdgcn--amdhsa" - - -define void @__threadfence() #1 { - fence syncscope(2) seq_cst - ret void -} - -define void @__threadfence_block() #1 { - fence syncscope(3) seq_cst - ret void -} - -define linkonce_odr spir_func i32 @__rocm_dp4a(i32 %in1, i32 %in2, i32 %in3) { - %val1 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:BYTE_0","=v,v,v"(i32 %in1, i32 %in2) - %ret1 = add i32 %val1, %in3 - %val2 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:BYTE_1","=v,v,v"(i32 %in1, i32 %in2) - %ret2 = add i32 %ret1, %val2 - %val3 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_2 src1_sel:BYTE_2","=v,v,v"(i32 %in1, i32 %in2) - %ret3 = add i32 %val3, %ret2 - %val4 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_3 src1_sel:BYTE_3","=v,v,v"(i32 %in1, i32 %in2) - %ret4 = add i32 %val4, %ret3 - ret i32 %ret4 -} - -define linkonce_odr spir_func i32 @__rocm_hfma(i32 %in1, i32 %in2, i32 %in3) { - tail call void asm "v_mac_f16 $0, $1, $2","v,v,v"(i32 %in1, i32 %in2, i32 %in3) - ret i32 %in3 -} - -define linkonce_odr spir_func i32 @__rocm_hadd(i32 %in1, i32 %in2) { - %val = tail call i32 asm "v_add_f16 $0, $1, $2","=v,v,v"(i32 %in1, i32 %in2) - ret i32 %val -} - -attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/src/hip_ldg.cpp b/projects/hip/src/hip_ldg.cpp index f3e593355a..549d3ae085 100644 --- a/projects/hip/src/hip_ldg.cpp +++ b/projects/hip/src/hip_ldg.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,23 +20,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include - #include "hip/hcc_detail/hip_ldg.h" +#include "hip/hcc_detail/hip_vector_types.h" __device__ char __ldg(const char* ptr) { - return ptr[0]; + return *ptr; } __device__ char2 __ldg(const char2* ptr) { - return ptr[0]; + return *ptr; } __device__ char4 __ldg(const char4* ptr) { - return ptr[0]; + return *ptr; } __device__ signed char __ldg(const signed char* ptr) @@ -169,6 +168,3 @@ __device__ double2 __ldg(const double2* ptr) { return ptr[0]; } - - - diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index f2ab6d19a0..821f64bc76 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,17 +25,115 @@ THE SOFTWARE. #include "hsa/hsa_ext_amd.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" #include "hip/hcc_detail/hip_texture.h" #include + + +// Internal HIP APIS: +namespace hip_internal { + +hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) +{ + hipError_t e = hipSuccess; + + stream = ihipSyncAndResolveStream(stream); + + + if ((dst == NULL) || (src == NULL)) { + e= hipErrorInvalidValue; + } else if (stream) { + try { + stream->locked_copyAsync(dst, src, sizeBytes, kind); + } + catch (ihipException ex) { + e = ex._code; + } + } else { + e = hipErrorInvalidValue; + } + + return e; +} + +// return 0 on success or -1 on error: +int sharePtr(void *ptr, ihipCtx_t *ctx, unsigned hipFlags) +{ + int ret = 0; + + auto device = ctx->getWriteableDevice(); + + hc::am_memtracker_update(ptr, device->_deviceId, hipFlags); + int peerCnt=0; + { + LockedAccessor_CtxCrit_t crit(ctx->criticalData()); + // the peerCnt always stores self so make sure the trace actually + peerCnt = crit->peerCnt(); + tprintf(DB_MEM, " allow access to %d other peer(s)\n", peerCnt-1); + if (peerCnt > 1) { + + //printf ("peer self access\n"); + + // TODOD - remove me: + for (auto iter = crit->_peers.begin(); iter!=crit->_peers.end(); iter++) { + tprintf (DB_MEM, " allow access to peer: %s%s\n", (*iter)->toString().c_str(), (iter == crit->_peers.begin()) ? " (self)":""); + }; + + hsa_status_t s = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, ptr); + if (s != HSA_STATUS_SUCCESS) { + ret = -1; + } + } + } + + return ret; +} + + + + +// Allocate a new pointer with am_alloc and share with all valid peers. +// Returns null-ptr if a memory error occurs (either allocation or sharing) +void * allocAndSharePtr(const char *msg, size_t sizeBytes, ihipCtx_t *ctx, unsigned amFlags, unsigned hipFlags) +{ + + void *ptr = nullptr; + + auto device = ctx->getWriteableDevice(); + + ptr = hc::am_alloc(sizeBytes, device->_acc, amFlags); + tprintf(DB_MEM, " alloc %s ptr:%p size:%zu on dev:%d\n", + msg, ptr, sizeBytes, device->_deviceId); + + if (ptr != nullptr) { + int r = sharePtr(ptr, ctx, hipFlags); + if (r != 0) { + ptr = nullptr; + } + } + + return ptr; +} + + +} // end namespace hip_internal + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- // Memory // // -hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) +// +//HIP uses several "app*" fields HC memory tracker to track state necessary for the HIP API. +//_appId : DeviceID. For device mem, this is device where the memory is physically allocated. +// For host or registered mem, this is the current device when the memory is allocated or registered. This device will have a GPUVM mapping for the host mem. +// +//_appAllocationFlags : These are flags provided by the user when allocation is performed. They are returned to user in hipHostGetFlags and other APIs. +// TODO - add more info here when available. +// +hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void* ptr) { HIP_INIT_API(attributes, ptr); @@ -51,10 +149,10 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) attributes->devicePointer = amPointerInfo._devicePointer; attributes->isManaged = 0; if(attributes->memoryType == hipMemoryTypeHost){ - attributes->hostPointer = ptr; + attributes->hostPointer = (void*)ptr; } if(attributes->memoryType == hipMemoryTypeDevice){ - attributes->devicePointer = ptr; + attributes->devicePointer = (void*)ptr; } attributes->allocationFlags = amPointerInfo._appAllocationFlags; attributes->device = amPointerInfo._appId; @@ -78,6 +176,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) return ihipLogStatus(e); } + hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsigned flags) { HIP_INIT_API(devicePointer, hostPointer, flags); @@ -102,56 +201,32 @@ hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsi return ihipLogStatus(e); } + hipError_t hipMalloc(void** ptr, size_t sizeBytes) { HIP_INIT_API(ptr, sizeBytes); - + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; + + auto ctx = ihipGetTlsDefaultCtx(); // return NULL pointer when malloc size is 0 if (sizeBytes == 0) { *ptr = NULL; - return ihipLogStatus(hipSuccess); - } + hip_status = hipSuccess; - auto ctx = ihipGetTlsDefaultCtx(); + } else if ((ctx==nullptr) || (ptr == nullptr)) { + hip_status = hipErrorInvalidValue; - if (ctx) { - auto device = ctx->getWriteableDevice(); - const unsigned am_flags = 0; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); - - - if (sizeBytes && (*ptr == NULL)) { - hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - int peerCnt=0; - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - // the peerCnt always stores self so make sure the trace actually - peerCnt = crit->peerCnt(); - tprintf(DB_MEM, " allocated device_mem ptr:%p size:%zu on dev:%d and allowed %d other peer(s) access\n", - *ptr, sizeBytes, device->_deviceId, peerCnt-1); - if (peerCnt > 1) { - - //printf ("peer self access\n"); - - // TODOD - remove me: - for (auto iter = crit->_peers.begin(); iter!=crit->_peers.end(); iter++) { - tprintf (DB_MEM, " allow access to peer: %s%s\n", (*iter)->toString().c_str(), (iter == crit->_peers.begin()) ? " (self)":""); - }; - - hsa_status_t e = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (e != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } - } } else { - hip_status = hipErrorMemoryAllocation; - } + auto device = ctx->getWriteableDevice(); + *ptr = hip_internal::allocAndSharePtr("device_mem", sizeBytes, ctx, 0/*amFlags*/, 0/*hipFlags*/); + + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; + } + + } return ihipLogStatus(hip_status); @@ -160,10 +235,14 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_API(ptr, sizeBytes, flags); - + HIP_INIT_CMD_API(ptr, sizeBytes, flags); + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; + if (HIP_SYNC_HOST_ALLOC) { + hipDeviceSynchronize(); + } + auto ctx = ihipGetTlsDefaultCtx(); if (sizeBytes == 0) { @@ -184,56 +263,41 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) } else { auto device = ctx->getWriteableDevice(); - if(HIP_COHERENT_HOST_ALLOC){ - // Force to allocate finedgrained system memory - *ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned); - if(sizeBytes < 1 && (*ptr == NULL)){ - hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, amHostCoherent); - } - tprintf(DB_MEM, " %s: finegrained system memory ptr=%p\n", __func__, *ptr); - } - else{ - // TODO - am_alloc requires writeable __acc, perhaps could be refactored? - // TODO - hipHostMallocMapped is be ignored on ROCM - all memory is mapped to host address space as WC. - *ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned); - if (*ptr == NULL) { - hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, flags); - // TODO-hipHostMallocPortable should map the host memory into all contexts, regardless of peer status. - int peerCnt=0; - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - peerCnt = crit->peerCnt(); - if (peerCnt > 1) { - hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - } - } - tprintf(DB_MEM, "allocated pinned_host ptr:%p size:%zu on dev:%d and allow access to %d other peer(s)\n", *ptr, sizeBytes, device->_deviceId, peerCnt-1); - } + unsigned amFlags = HIP_COHERENT_HOST_ALLOC ? amHostCoherent : amHostPinned; + + *ptr = hip_internal::allocAndSharePtr(HIP_COHERENT_HOST_ALLOC ? "finegrained_host":"pinned_host", + sizeBytes, ctx, amFlags, flags); + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; } } } + + if (HIP_SYNC_HOST_ALLOC) { + hipDeviceSynchronize(); + } return ihipLogStatus(hip_status); } +// Deprecated function: hipError_t hipMallocHost(void** ptr, size_t sizeBytes) { return hipHostMalloc(ptr, sizeBytes, 0); } + +// Deprecated function: hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) { return hipHostMalloc(ptr, sizeBytes, flags); }; + // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { - HIP_INIT_API(ptr, pitch, width, height); - + HIP_INIT_CMD_API(ptr, pitch, width, height); + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if(width == 0 || height == 0) @@ -250,21 +314,10 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height auto device = ctx->getWriteableDevice(); const unsigned am_flags = 0; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); + *ptr = hip_internal::allocAndSharePtr("device_pitch", sizeBytes, ctx, am_flags, 0); if (sizeBytes && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - if (crit->peerCnt() > 1) { // peerCnt includes self so only call allow_access if other peers involved: - hsa_status_t hsa_status = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (hsa_status != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } } } else { hip_status = hipErrorMemoryAllocation; @@ -284,8 +337,8 @@ hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannel hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { - HIP_INIT_API(array, desc, width, height, flags); - + HIP_INIT_CMD_API(array, desc, width, height, flags); + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -299,40 +352,30 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, void ** ptr = &array[0]->data; if (ctx) { - auto device = ctx->getWriteableDevice(); const unsigned am_flags = 0; const size_t size = width*height; + size_t allocSize = 0; switch(desc->f) { case hipChannelFormatKindSigned: - *ptr = hc::am_alloc(size*sizeof(int), device->_acc, am_flags); + allocSize = size * sizeof(int); break; case hipChannelFormatKindUnsigned: - *ptr = hc::am_alloc(size*sizeof(unsigned int), device->_acc, am_flags); + allocSize = size * sizeof(unsigned int); break; case hipChannelFormatKindFloat: - *ptr = hc::am_alloc(size*sizeof(float), device->_acc, am_flags); + allocSize = size * sizeof(float); break; case hipChannelFormatKindNone: - *ptr = hc::am_alloc(size*sizeof(size_t), device->_acc, am_flags); + allocSize = size * sizeof(size_t); break; default: hip_status = hipErrorUnknown; break; } + *ptr = hip_internal::allocAndSharePtr("device_array", allocSize, ctx, am_flags, 0); if (size && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - if (crit->peerCnt() > 1) { // peerCnt includes self so only call allow_access if other peers involved: - hsa_status_t hsa_status = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (hsa_status != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } } } else { @@ -366,6 +409,8 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) return ihipLogStatus(hip_status); } + +// TODO - need to fix several issues here related to P2P access, host memory fallback. hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) { HIP_INIT_API(hostPtr, sizeBytes, flags); @@ -385,19 +430,21 @@ hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) hip_status = hipErrorHostMemoryAlreadyRegistered; } else { auto ctx = ihipGetTlsDefaultCtx(); - if(hostPtr == NULL){ + if (hostPtr == NULL) { return ihipLogStatus(hipErrorInvalidValue); } + //TODO-test : multi-gpu access to registered host memory. if (ctx) { - auto device = ctx->getWriteableDevice(); if(flags == hipHostRegisterDefault || flags == hipHostRegisterPortable || flags == hipHostRegisterMapped){ + auto device = ctx->getWriteableDevice(); std::vectorvecAcc; for(int i=0;i_acc); } am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], vecAcc.size()); + hc::am_memtracker_update(hostPtr, device->_deviceId, flags); - tprintf(DB_MEM, " %s registered ptr=%p\n", __func__, hostPtr); + tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__, hostPtr, vecAcc.size()); if(am_status == AM_SUCCESS){ hip_status = hipSuccess; } else { @@ -429,9 +476,9 @@ hipError_t hipHostUnregister(void *hostPtr) return ihipLogStatus(hip_status); } -hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind) +hipError_t hipMemcpyToSymbol(const void* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_API(symbolName, src, count, offset, kind); + HIP_INIT_CMD_API(symbolName, src, count, offset, kind); if(symbolName == nullptr) { @@ -442,24 +489,66 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou hc::accelerator acc = ctx->getDevice()->_acc; - void *ptr = acc.get_symbol_address(symbolName); - tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, ptr); + void *dst = acc.get_symbol_address((const char*) symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); - if(ptr == nullptr) + if(dst == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); } hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); - stream->locked_copySync(ptr, src, count + offset, kind); + if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) + { + stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); + // acc.memcpy_symbol(dst, (void*)src, count+offset); + } else { + return ihipLogStatus(hipErrorInvalidValue); + } return ihipLogStatus(hipSuccess); } -hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) + +hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_API(symbolName, src, count, offset, kind, stream); + HIP_INIT_CMD_API(symbolName, dst, count, offset, kind); + + if(symbolName == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + auto ctx = ihipGetTlsDefaultCtx(); + + hc::accelerator acc = ctx->getDevice()->_acc; + + void *src = acc.get_symbol_address((const char*) symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); + + if(dst == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); + + if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) + { + stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); + } + else { + return ihipLogStatus(hipErrorInvalidValue); + } + + return ihipLogStatus(hipSuccess); +} + + +hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) +{ + HIP_INIT_CMD_API(symbolName, src, count, offset, kind, stream); if(symbolName == nullptr) { @@ -472,17 +561,17 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ hc::accelerator acc = ctx->getDevice()->_acc; - void *ptr = acc.get_symbol_address(symbolName); - tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, ptr); + void *dst = acc.get_symbol_address((const char*) symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); - if(ptr == nullptr) + if(dst == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); } if (stream) { try { - stream->locked_copyAsync(ptr, src, count + offset, kind); + stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count, offset, kind); } catch (ihipException ex) { e = ex._code; @@ -492,14 +581,51 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ } return ihipLogStatus(e); +} +hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) +{ + HIP_INIT_CMD_API(symbolName, dst, count, offset, kind, stream); + + if(symbolName == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + hipError_t e = hipSuccess; + + auto ctx = ihipGetTlsDefaultCtx(); + + hc::accelerator acc = ctx->getDevice()->_acc; + + void *src = acc.get_symbol_address((const char*) symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, src); + + if(src == nullptr || dst == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + stream = ihipSyncAndResolveStream(stream); + if (stream) { + try { + stream->lockedSymbolCopyAsync(acc, dst, src, count, offset, kind); + } + catch (ihipException ex) { + e = ex._code; + } + } else { + e = hipErrorInvalidValue; + } + + return ihipLogStatus(e); } //--- hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) { - HIP_INIT_API(dst, src, sizeBytes, kind); + HIP_INIT_CMD_API(dst, src, sizeBytes, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -518,9 +644,10 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind return ihipLogStatus(e); } + hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -539,9 +666,10 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) return ihipLogStatus(e); } + hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -560,9 +688,10 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) return ihipLogStatus(e); } + hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -581,9 +710,10 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte return ihipLogStatus(e); } + hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -604,37 +734,11 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) -// Internal copy sync: -namespace hip_internal { - -hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) -{ - hipError_t e = hipSuccess; - - stream = ihipSyncAndResolveStream(stream); - - - if ((dst == NULL) || (src == NULL)) { - e= hipErrorInvalidValue; - } else if (stream) { - try { - stream->locked_copyAsync(dst, src, sizeBytes, kind); - } - catch (ihipException ex) { - e = ex._code; - } - } else { - e = hipErrorInvalidValue; - } - - return e; -} -} // end namespace hip_internal hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, kind, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, kind, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, kind, stream)); @@ -643,21 +747,21 @@ hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcp hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyHostToDevice, stream)); } hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToDevice, stream)); } hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToHost, stream)); } @@ -666,7 +770,7 @@ hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, h hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_API(dst, dpitch, src, spitch, width, height, kind); + HIP_INIT_CMD_API(dst, dpitch, src, spitch, width, height, kind); if(width > dpitch || width > spitch) return ihipLogStatus(hipErrorUnknown); @@ -692,7 +796,7 @@ hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_API(dst, wOffset, hOffset, src, spitch, width, height, kind); + HIP_INIT_CMD_API(dst, wOffset, hOffset, src, spitch, width, height, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -745,7 +849,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - HIP_INIT_API(dst, wOffset, hOffset, src, count, kind); + HIP_INIT_CMD_API(dst, wOffset, hOffset, src, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -765,10 +869,11 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, // TODO - make member function of stream? template -hc::completion_future +void ihipMemsetKernel(hipStream_t stream, LockedAccessor_StreamCrit_t &crit, - T * ptr, T val, size_t sizeBytes) + T * ptr, T val, size_t sizeBytes, + hc::completion_future *cf) { int wg = std::min((unsigned)8, stream->getDevice()->_computeUnits); const int threads_per_wg = 256; @@ -782,7 +887,7 @@ ihipMemsetKernel(hipStream_t stream, hc::extent<1> ext(threads); auto ext_tile = ext.tile(threads_per_wg); - hc::completion_future cf = + *cf = hc::parallel_for_each( crit->_av, ext_tile, @@ -798,13 +903,12 @@ ihipMemsetKernel(hipStream_t stream, } }); - return cf; } // TODO-sync: function is async unless target is pinned host memory - then these are fully sync. hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream ) { - HIP_INIT_API(dst, value, sizeBytes, stream); + HIP_INIT_CMD_API(dst, value, sizeBytes, stream); hipError_t e = hipSuccess; @@ -813,14 +917,16 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s if (stream) { auto crit = stream->lockopen_preKernelCommand(); + stream->ensureHaveQueue(crit); + hc::completion_future cf ; if ((sizeBytes & 0x3) == 0) { // use a faster dword-per-workitem copy: try { value = value & 0xff; - unsigned value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(unsigned)); + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -828,7 +934,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s } else { // use a slow byte-per-workitem copy: try { - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes); + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -841,7 +947,6 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s if (HIP_API_BLOCKING) { tprintf (DB_SYNC, "%s LAUNCH_BLOCKING wait for hipMemsetAsync.\n", ToString(stream).c_str()); cf.wait(); - //tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed [stream:%p].\n", __func__, (void*)stream); } } else { e = hipErrorInvalidValue; @@ -853,25 +958,26 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) { - hipStream_t stream = hipStreamNull; - // TODO - call an ihip memset so HIP_TRACE is correct. - HIP_INIT_API(dst, value, sizeBytes, stream); + HIP_INIT_CMD_API(dst, value, sizeBytes); hipError_t e = hipSuccess; + hipStream_t stream = hipStreamNull; + // TODO - call an ihip memset so HIP_TRACE is correct. stream = ihipSyncAndResolveStream(stream); if (stream) { auto crit = stream->lockopen_preKernelCommand(); + stream->ensureHaveQueue(crit); hc::completion_future cf ; if ((sizeBytes & 0x3) == 0) { // use a faster dword-per-workitem copy: try { value = value & 0xff; - unsigned value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(unsigned)); + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -879,7 +985,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) } else { // use a slow byte-per-workitem copy: try { - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes); + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -892,9 +998,60 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) if (HIP_LAUNCH_BLOCKING) { - tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset [stream:%p].\n", __func__, (void*)stream); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset in %s.\n", __func__, ToString(stream).c_str()); cf.wait(); - tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed [stream:%p].\n", __func__, (void*)stream); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed in %s.\n", __func__, ToString(stream).c_str()); + } + } else { + e = hipErrorInvalidValue; + } + + return ihipLogStatus(e); +} + +hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes ) +{ + HIP_INIT_CMD_API(dst, value, sizeBytes); + + hipError_t e = hipSuccess; + + hipStream_t stream = hipStreamNull; + // TODO - call an ihip memset so HIP_TRACE is correct. + stream = ihipSyncAndResolveStream(stream); + + if (stream) { + auto crit = stream->lockopen_preKernelCommand(); + + stream->ensureHaveQueue(crit); + hc::completion_future cf ; + + if ((sizeBytes & 0x3) == 0) { + // use a faster dword-per-workitem copy: + try { + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); + } + catch (std::exception &ex) { + e = hipErrorInvalidValue; + } + } else { + // use a slow byte-per-workitem copy: + try { + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); + } + catch (std::exception &ex) { + e = hipErrorInvalidValue; + } + } + cf.wait(); + + stream->lockclose_postKernelCommand("hipMemsetD8", &crit->_av); + + + if (HIP_LAUNCH_BLOCKING) { + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset in %s.\n", __func__, ToString(stream).c_str()); + cf.wait(); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed in %s.\n", __func__, ToString(stream).c_str()); } } else { e = hipErrorInvalidValue; @@ -937,6 +1094,28 @@ hipError_t hipMemGetInfo (size_t *free, size_t *total) return ihipLogStatus(e); } +hipError_t hipMemPtrGetInfo(void *ptr, size_t *size) +{ + HIP_INIT_API(ptr, size); + + hipError_t e = hipSuccess; + + if(ptr != nullptr && size != nullptr){ + hc::accelerator acc; + hc::AmPointerInfo amPointerInfo(NULL, NULL, 0, acc, 0, 0); + am_status_t status = hc::am_memtracker_getinfo(&amPointerInfo, ptr); + if(status == AM_SUCCESS){ + *size = amPointerInfo._sizeBytes; + }else{ + e = hipErrorInvalidValue; + } + }else{ + e = hipErrorInvalidValue; + } + return ihipLogStatus(e); +} + + hipError_t hipFree(void* ptr) { HIP_INIT_API(ptr); @@ -964,6 +1143,7 @@ hipError_t hipFree(void* ptr) return ihipLogStatus(hipStatus); } + hipError_t hipHostFree(void* ptr) { HIP_INIT_API(ptr); @@ -991,6 +1171,8 @@ hipError_t hipHostFree(void* ptr) return ihipLogStatus(hipStatus); }; + +// Deprecated: hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); @@ -1033,7 +1215,7 @@ hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDevi } else hipStatus = hipErrorInvalidDevicePointer; - return hipStatus; + return ihipLogStatus(hipStatus); } @@ -1052,47 +1234,64 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){ } else hipStatus = hipErrorInvalidResourceHandle; - + ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) handle; // Save the size of the pointer to hipIpcMemHandle - (*handle)->psize = psize; + iHandle->psize = psize; +#if USE_IPC // Create HSA ipc memory hsa_status_t hsa_status = - hsa_amd_ipc_memory_create(devPtr, psize, &(*handle)->ipc_handle); + hsa_amd_ipc_memory_create(devPtr, psize, (hsa_amd_ipc_memory_t*) &(iHandle->ipc_handle)); if(hsa_status!= HSA_STATUS_SUCCESS) hipStatus = hipErrorMemoryAllocation; +#else + hipStatus = hipErrorRuntimeOther; +#endif - return hipStatus; + return ihipLogStatus(hipStatus); } hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags){ -// HIP_INIT_API ( devPtr, handle.handle , flags); + HIP_INIT_API ( devPtr, &handle , flags); hipError_t hipStatus = hipSuccess; +#if USE_IPC // Get the current device agent. hc::accelerator acc; hsa_agent_t *agent = static_cast(acc.get_hsa_agent()); if(!agent) return hipErrorInvalidResourceHandle; + ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) &handle; //Attach ipc memory - hsa_status_t hsa_status = - hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); - if(hsa_status != HSA_STATUS_SUCCESS) - hipStatus = hipErrorMapBufferObjectFailed; - - return hipStatus; + auto ctx= ihipGetTlsDefaultCtx(); + { + LockedAccessor_CtxCrit_t crit(ctx->criticalData()); + // the peerCnt always stores self so make sure the trace actually + hsa_status_t hsa_status = + hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, crit->peerCnt(), crit->peerAgents(), devPtr); + if(hsa_status != HSA_STATUS_SUCCESS) + hipStatus = hipErrorMapBufferObjectFailed; + } +#else + hipStatus = hipErrorRuntimeOther; +#endif + return ihipLogStatus(hipStatus); } hipError_t hipIpcCloseMemHandle(void *devPtr){ HIP_INIT_API ( devPtr ); hipError_t hipStatus = hipSuccess; +#if USE_IPC hsa_status_t hsa_status = hsa_amd_ipc_memory_detach(devPtr); if(hsa_status != HSA_STATUS_SUCCESS) return hipErrorInvalidResourceHandle; - return hipStatus; +#else + hipStatus = hipErrorRuntimeOther; +#endif + return ihipLogStatus(hipStatus); } // hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle){ diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index badeac2dcd..b359e7a63c 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,18 +23,72 @@ THE SOFTWARE. #include #include #include +#include #include +#include +#include #include "hsa/hsa.h" #include "hsa/hsa_ext_amd.h" #include "hsa/amd_hsa_kernel_code.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //TODO Use Pool APIs from HCC to get memory regions. +#include +inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew = 0) { + assert(Align != 0u && "Align can't be 0."); + Skew %= Align; + return (Value + Align - 1 - Skew) / Align * Align + Skew; +} + +struct ihipKernArgInfo{ + std::vector Size; + std::vector Align; + std::vector ArgType; + std::vector ArgName; + uint32_t totalSize; +}; + +std::map kernelArguments; + +struct MyElfNote { + uint32_t n_namesz = 0; + uint32_t n_descsz = 0; + uint32_t n_type = 0; + + MyElfNote() = default; +}; + +struct ihipModuleSymbol_t{ + uint64_t _object; // The kernel object. + uint32_t _groupSegmentSize; + uint32_t _privateSegmentSize; + std::string _name; // TODO - review for performance cost. Name is just used for debug. +}; + +template <> +std::string ToString(hipFunction_t v) +{ + std::ostringstream ss; + ss << "0x" << std::hex << v->_object; + return ss.str(); +}; + + +#define CHECK_HSA(hsaStatus, hipStatus) \ +if (hsaStatus != HSA_STATUS_SUCCESS) {\ + return hipStatus;\ +} + +#define CHECKLOG_HSA(hsaStatus, hipStatus) \ +if (hsaStatus != HSA_STATUS_SUCCESS) {\ + return ihipLogStatus(hipStatus);\ +} + namespace hipdrv { hsa_status_t findSystemRegions(hsa_region_t region, void *data){ @@ -103,6 +157,7 @@ uint64_t ElfSize(const void *emi){ return total_size; } + hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ HIP_INIT_API(module, fname); hipError_t ret = hipSuccess; @@ -144,9 +199,57 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ (*module)->ptr = p; (*module)->size = size; in.seekg(0, std::ios::beg); - std::copy(std::istreambuf_iterator(in), - std::istreambuf_iterator(), ptr); + std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), ptr); +/* + Elf *e = elf_memory((char*)p, size); + if(elf_kind(e) != ELF_K_ELF){ + return ihipLogStatus(hipErrorInvalidValue); + } + size_t numpHdrs; + if(elf_getphdrnum(e, &numpHdrs) != 0){ + return ihipLogStatus(hipErrorInvalidValue); + } + for(size_t i=0;i= sizeof(int)){ + char* ptr = (char*) p + pHdr.p_offset; + char* segmentEnd = ptr + pHdr.p_filesz; + while(ptr < segmentEnd){ + MyElfNote *note = (MyElfNote*) ptr; + char *name = (char*) ¬e[1]; + char *desc = name + alignTo(note->n_namesz, sizeof(int)); + if (note->n_type == 8) { + std::string metadatastr((const char*)desc, (size_t)note->n_descsz); + AMDGPU::RuntimeMD::Program::Metadata meta; + meta = meta.fromYAML(metadatastr); + for(int i=0;in_namesz, sizeof(int)) + + alignTo(note->n_descsz, sizeof(int)); + } + } + } +*/ status = hsa_code_object_deserialize(ptr, size, NULL, &(*module)->object); if(status != HSA_STATUS_SUCCESS){ @@ -154,15 +257,20 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } + CHECKLOG_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); + CHECKLOG_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_freeze((*module)->executable, NULL); + CHECKLOG_HSA(status, hipErrorNotInitialized); } } return ihipLogStatus(ret); } + hipError_t hipModuleUnload(hipModule_t hmod) { // TODO - improve this synchronization so it is thread-safe. @@ -185,47 +293,64 @@ hipError_t hipModuleUnload(hipModule_t hmod) { ret = hipErrorInvalidValue; } + for(auto f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + delete *f; + } delete hmod; return ihipLogStatus(ret); } -hipError_t ihipModuleGetFunction(hipFunction_t *func, hipModule_t hmod, const char *name){ + +hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char *name) +{ auto ctx = ihipGetTlsDefaultCtx(); hipError_t ret = hipSuccess; - if(name == nullptr){ + if (name == nullptr){ return ihipLogStatus(hipErrorInvalidValue); } - if(ctx == nullptr){ + if (ctx == nullptr){ ret = hipErrorInvalidContext; - }else{ - *func = new ihipFunction_t(name); - hmod->registerFunction(*func); + } else { + std::string str(name); + for(auto f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + if((*f)->_name == str) { + *func = *f; + return ret; + } + } + ihipModuleSymbol_t *sym = new ihipModuleSymbol_t; int deviceId = ctx->getDevice()->_deviceId; ihipDevice_t *currentDevice = ihipGetDevice(deviceId); hsa_agent_t gpuAgent = (hsa_agent_t)currentDevice->_hsaAgent; hsa_status_t status; - status = hsa_executable_load_code_object(hmod->executable, gpuAgent, hmod->object, NULL); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } - - status = hsa_executable_freeze(hmod->executable, NULL); - status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &(*func)->_kernelSymbol); + hsa_executable_symbol_t symbol; + status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &symbol); if(status != HSA_STATUS_SUCCESS){ return ihipLogStatus(hipErrorNotFound); } - status = hsa_executable_symbol_get_info((*func)->_kernelSymbol, + status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, - &(*func)->_kernel); + &sym->_object); + CHECK_HSA(status, hipErrorNotFound); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } + status = hsa_executable_symbol_get_info(symbol, + HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, + &sym->_groupSegmentSize); + CHECK_HSA(status, hipErrorNotFound); + + status = hsa_executable_symbol_get_info(symbol, + HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, + &sym->_privateSegmentSize); + CHECK_HSA(status, hipErrorNotFound); + + sym->_name = name; + *func = sym; + hmod->funcTrack.push_back(*func); } return ihipLogStatus(ret); } @@ -234,20 +359,17 @@ hipError_t ihipModuleGetFunction(hipFunction_t *func, hipModule_t hmod, const ch hipError_t hipModuleGetFunction(hipFunction_t *hfunc, hipModule_t hmod, const char *name){ HIP_INIT_API(hfunc, hmod, name); - return ihipModuleGetFunction(hfunc, hmod, name); + return ihipModuleGetSymbol(hfunc, hmod, name); } -hipError_t hipModuleLaunchKernel(hipFunction_t f, - uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, - uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, - uint32_t sharedMemBytes, hipStream_t hStream, - void **kernelParams, void **extra) +hipError_t ihipModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, + size_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra, + hipEvent_t startEvent, hipEvent_t stopEvent) { - HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, - blockDimX, blockDimY, blockDimZ, - sharedMemBytes, hStream, - kernelParams, extra); auto ctx = ihipGetTlsDefaultCtx(); hipError_t ret = hipSuccess; @@ -263,42 +385,39 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, void *config[5] = {0}; size_t kernArgSize; - if(extra != NULL){ + if(kernelParams != NULL){ + std::string name = f->_name; + struct ihipKernArgInfo pl = kernelArguments[name]; + char* argBuf = (char*)malloc(pl.totalSize); + memset(argBuf, 0, pl.totalSize); + int index = 0; + for(int i=0;i_kernelSymbol, - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, - &groupSegmentSize); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - - uint32_t privateSegmentSize; - status = hsa_executable_symbol_get_info(f->_kernelSymbol, - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, - &privateSegmentSize); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - privateSegmentSize += sharedMemBytes; /* Kernel argument preparation. */ grid_launch_parm lp; - hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f->_kernelName); + lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. + hStream = ihipPreLaunchKernel(hStream, dim3(globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ), dim3(localWorkSizeX, localWorkSizeY, localWorkSizeZ), &lp, f->_name.c_str()); -#if USE_DISPATCH_HSA_KERNEL hsa_kernel_dispatch_packet_t aql; @@ -307,90 +426,84 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, //aql.completion_signal._handle = 0; //aql.kernarg_address = 0; - aql.workgroup_size_x = blockDimX; - aql.workgroup_size_y = blockDimY; - aql.workgroup_size_z = blockDimZ; - aql.grid_size_x = blockDimX * gridDimX; - aql.grid_size_y = blockDimY * gridDimY; - aql.grid_size_z = blockDimZ * gridDimZ; - aql.group_segment_size = groupSegmentSize; - aql.private_segment_size = privateSegmentSize; - aql.kernel_object = f->_kernel; + aql.workgroup_size_x = localWorkSizeX; + aql.workgroup_size_y = localWorkSizeY; + aql.workgroup_size_z = localWorkSizeZ; + aql.grid_size_x = globalWorkSizeX; + aql.grid_size_y = globalWorkSizeY; + aql.grid_size_z = globalWorkSizeZ; + aql.group_segment_size = f->_groupSegmentSize + sharedMemBytes; + aql.private_segment_size = f->_privateSegmentSize; + aql.kernel_object = f->_object; aql.setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; aql.header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | - (1 << HSA_PACKET_HEADER_BARRIER) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + (1 << HSA_PACKET_HEADER_BARRIER); // TODO - honor queue setting for execute_in_order - lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize); -#else + if (HCC_OPT_FLUSH) { + aql.header |= (HSA_FENCE_SCOPE_AGENT << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | + (HSA_FENCE_SCOPE_AGENT << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + } else { + aql.header |= (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | + (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + }; - /* - Create signal - */ - hsa_signal_t signal; - status = hsa_signal_create(1, 0, NULL, &signal); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); + hc::completion_future cf; + + lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, + (startEvent || stopEvent) ? &cf : nullptr); + + + if (startEvent) { + startEvent->attachToCompletionFuture(&cf, hipEventTypeStartCommand); + } + if (stopEvent) { + stopEvent->attachToCompletionFuture (&cf, hipEventTypeStopCommand); } - /* - Allocate kernarg - */ - void *kern = nullptr; - hsa_amd_memory_pool_t *pool = reinterpret_cast(lp.av->get_hsa_kernarg_region()); - status = hsa_amd_memory_pool_allocate(*pool, kernArgSize, 0, &kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); + if(kernelParams != NULL){ + free(config[1]); } - status = hsa_amd_agents_allow_access(1, (hsa_agent_t*)lp.av->get_hsa_agent(), 0, kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - memcpy(kern, config[1], kernArgSize); - - - /* - Launch AQL packet - */ - hStream->launchModuleKernel(*lp.av, signal, blockDimX, blockDimY, blockDimZ, - gridDimX, gridDimY, gridDimZ, groupSegmentSize, privateSegmentSize, kern, kernArgSize, f->_kernel); - - - /* - Wait for signal - */ - - hsa_signal_value_t value = hsa_signal_wait_acquire(signal, HSA_SIGNAL_CONDITION_LT, 1, UINT64_MAX, HSA_WAIT_STATE_BLOCKED); - - /* - Destroy kernarg - */ - status = hsa_amd_memory_pool_free(kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - - /* - Destroy the signal - */ - status = hsa_signal_destroy(signal); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - -#endif // USE_DISPATCH_HSA_KERNEL - - - ihipPostLaunchKernel(f->_kernelName, hStream, lp); - + ihipPostLaunchKernel(f->_name.c_str(), hStream, lp); } - return ihipLogStatus(ret); + return ret; } +hipError_t hipModuleLaunchKernel(hipFunction_t f, + uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, + uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, + uint32_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra) +{ + HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, + blockDimX, blockDimY, blockDimZ, + sharedMemBytes, hStream, + kernelParams, extra); + return ihipLogStatus(ihipModuleLaunchKernel(f, + blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, + blockDimX, blockDimY, blockDimZ, + sharedMemBytes, hStream, kernelParams, extra, + nullptr, nullptr)); +} + + +hipError_t hipHccModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, + size_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra, + hipEvent_t startEvent, hipEvent_t stopEvent) +{ + HIP_INIT_API(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, + localWorkSizeX, localWorkSizeY, localWorkSizeZ, + sharedMemBytes, hStream, + kernelParams, extra); + return ihipLogStatus(ihipModuleLaunchKernel(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, + localWorkSizeX, localWorkSizeY, localWorkSizeZ, + sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent)); +} hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipModule_t hmod, const char* name) @@ -405,9 +518,9 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, } else{ hipFunction_t func; - ihipModuleGetFunction(&func, hmod, name); + ihipModuleGetSymbol(&func, hmod, name); *bytes = PrintSymbolSizes(hmod->ptr, name) + sizeof(amd_kernel_code_t); - *dptr = reinterpret_cast(func->_kernel); + *dptr = reinterpret_cast(func->_object); return ihipLogStatus(ret); } } @@ -419,7 +532,7 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) hipError_t ret = hipSuccess; if(image == NULL || module == NULL){ return ihipLogStatus(hipErrorNotInitialized); - }else{ + } else { auto ctx = ihipGetTlsDefaultCtx(); *module = new ihipModule_t; int deviceId = ctx->getDevice()->_deviceId; @@ -452,11 +565,13 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } + CHECKLOG_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); + CHECKLOG_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_freeze((*module)->executable, NULL); + CHECKLOG_HSA(status, hipErrorNotInitialized); } return ihipLogStatus(ret); } - - diff --git a/projects/hip/src/hip_peer.cpp b/projects/hip/src/hip_peer.cpp index b7dca06e5f..984110a6b5 100644 --- a/projects/hip/src/hip_peer.cpp +++ b/projects/hip/src/hip_peer.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" @@ -31,7 +31,7 @@ THE SOFTWARE. // There are two flavors: // - one where contexts are specified with hipCtx_t type. // - one where contexts are specified with integer deviceIds, that are mapped to the primary context for that device. -// The implementation contains a set of internal ihip* functions which operate on contexts. Then the +// The implementation contains a set of internal ihip* functions which operate on contexts. Then the // public APIs are thin wrappers which call into this internal implementations. // TODO - actually not yet - currently the integer deviceId flavors just call the context APIs. need to fix. @@ -46,16 +46,16 @@ hipError_t ihipDeviceCanAccessPeer (int* canAccessPeer, hipCtx_t thisCtx, hipCtx if (thisCtx == peerCtx) { *canAccessPeer = 0; - tprintf(DB_MEM, "Can't be peer to self. (this=%s, peer=%s)\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "Can't be peer to self. (this=%s, peer=%s)\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); } else if (HIP_FORCE_P2P_HOST & 0x2) { *canAccessPeer = false; - tprintf(DB_MEM, "HIP_FORCE_P2P_HOST denies peer access this=%s peer=%s canAccessPeer=%d\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); + tprintf(DB_MEM, "HIP_FORCE_P2P_HOST denies peer access this=%s peer=%s canAccessPeer=%d\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); } else { *canAccessPeer = peerCtx->getDevice()->_acc.get_is_peer(thisCtx->getDevice()->_acc); - tprintf(DB_MEM, "deviceCanAccessPeer this=%s peer=%s canAccessPeer=%d\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); + tprintf(DB_MEM, "deviceCanAccessPeer this=%s peer=%s canAccessPeer=%d\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); } } else { @@ -99,14 +99,14 @@ hipError_t ihipDisablePeerAccess (hipCtx_t peerCtx) LockedAccessor_CtxCrit_t peerCrit(peerCtx->criticalData()); bool changed = peerCrit->removePeerWatcher(peerCtx, thisCtx); if (changed) { - tprintf(DB_MEM, "device %s disable access to memory allocated on peer:%s\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "device %s disable access to memory allocated on peer:%s\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); // Update the peers for all memory already saved in the tracker: am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(), peerCrit->peerAgents()); } else { err = hipErrorPeerAccessNotEnabled; // never enabled P2P access. } - } + } } else { err = hipErrorInvalidDevice; } @@ -133,8 +133,8 @@ hipError_t ihipEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags) // Add thisCtx to peerCtx's access list so that new allocations on peer will be made visible to this device: bool isNewPeer = peerCrit->addPeerWatcher(peerCtx, thisCtx); if (isNewPeer) { - tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(), peerCrit->peerAgents()); } else { err = hipErrorPeerAccessAlreadyEnabled; diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index 8350035357..d7f8717725 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" @@ -45,12 +45,17 @@ hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags) //Note this is an execute_in_order queue, so all kernels submitted will atuomatically wait for prev to complete: //This matches CUDA stream behavior: - auto istream = new ihipStream_t(ctx, acc.create_view(), flags); + { + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_CtxCrit_t ctxCrit(ctx->criticalData()); - ctx->locked_addStream(istream); + auto istream = new ihipStream_t(ctx, ctx->createOrStealQueue(ctxCrit), flags); - *stream = istream; - tprintf(DB_SYNC, "hipStreamCreate, stream=%p\n", *stream); + ctxCrit->addStream(istream); + *stream = istream; + } + + tprintf(DB_SYNC, "hipStreamCreate, %s\n", ToString(*stream).c_str()); } else { e = hipErrorInvalidDevice; } @@ -120,8 +125,14 @@ hipError_t hipStreamQuery(hipStream_t stream) stream = device->_defaultStream; } - LockedAccessor_StreamCrit_t crit(stream->_criticalData); - int pendingOps = crit->_av.get_pending_async_ops(); + int pendingOps = 0; + + { + LockedAccessor_StreamCrit_t crit(stream->_criticalData); + if (crit->_hasQueue) { + pendingOps = crit->_av.get_pending_async_ops(); + } + } hipError_t e = (pendingOps > 0) ? hipErrorNotReady : hipSuccess; @@ -203,7 +214,7 @@ hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback { HIP_INIT_API(stream, callback, userData, flags); hipError_t e = hipSuccess; - //--- explicitly synchronize stream to add callback routines + //--- explicitly synchronize stream to add callback routines hipStreamSynchronize(stream); callback(stream, e, userData); return ihipLogStatus(e); diff --git a/projects/hip/src/hip_util.h b/projects/hip/src/hip_util.h index 34a80ed205..8c4d19bb40 100644 --- a/projects/hip/src/hip_util.h +++ b/projects/hip/src/hip_util.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_UTIL_H -#define HIP_UTIL_H +#ifndef HIP_INCLUDE_HCC_DETAIL_HIP_UTIL_H +#define HIP_INCLUDE_HCC_DETAIL_HIP_UTIL_H #include #include diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp new file mode 100644 index 0000000000..3472216309 --- /dev/null +++ b/projects/hip/src/math_functions.cpp @@ -0,0 +1,1023 @@ + +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +#include +#include +#include +#include "device_util.h" +#include "hip/hcc_detail/device_functions.h" +#include "hip/hip_runtime.h" + +__device__ float acosf(float x) +{ + return hc::precise_math::acosf(x); +} +__device__ float acoshf(float x) +{ + return hc::precise_math::acoshf(x); +} +__device__ float asinf(float x) +{ + return hc::precise_math::asinf(x); +} +__device__ float asinhf(float x) +{ + return hc::precise_math::asinhf(x); +} +__device__ float atan2f(float y, float x) +{ + return hc::precise_math::atan2f(y, x); +} +__device__ float atanf(float x) +{ + return hc::precise_math::atanf(x); +} +__device__ float atanhf(float x) +{ + return hc::precise_math::atanhf(x); +} +__device__ float cbrtf(float x) +{ + return hc::precise_math::cbrtf(x); +} +__device__ float ceilf(float x) +{ + return hc::precise_math::ceilf(x); +} +__device__ float copysignf(float x, float y) +{ + return hc::precise_math::copysignf(x, y); +} +__device__ float cosf(float x) +{ + return hc::precise_math::cosf(x); +} +__device__ float coshf(float x) +{ + return hc::precise_math::coshf(x); +} +__device__ float cyl_bessel_i0f(float x); +__device__ float cyl_bessel_i1f(float x); +__device__ float erfcf(float x) +{ + return hc::precise_math::erfcf(x); +} +__device__ float erfcinvf(float y) +{ + return __hip_erfinvf(1 - y); +} +__device__ float erfcxf(float x) +{ + return hc::precise_math::expf(x*x)*hc::precise_math::erfcf(x); +} +__device__ float erff(float x) +{ + return hc::precise_math::erff(x); +} +__device__ float erfinvf(float y) +{ + return __hip_erfinvf(y); +} +__device__ float exp10f(float x) +{ + return hc::precise_math::exp10f(x); +} +__device__ float exp2f(float x) +{ + return hc::precise_math::exp2f(x); +} +__device__ float expf(float x) +{ + return hc::precise_math::expf(x); +} +__device__ float expm1f(float x) +{ + return hc::precise_math::expm1f(x); +} +__device__ int abs(int x) +{ + return x >= 0 ? x : -x; // TODO - optimize with OCML +} +__device__ float fabsf(float x) +{ + return hc::precise_math::fabsf(x); +} +__device__ float fdimf(float x, float y) +{ + return hc::precise_math::fdimf(x, y); +} +__device__ float fdividef(float x, float y) +{ + return x/y; +} +__device__ float floorf(float x) +{ + return hc::precise_math::floorf(x); +} +__device__ float fmaf(float x, float y, float z) +{ + return hc::precise_math::fmaf(x, y, z); +} +__device__ float fmaxf(float x, float y) +{ + return hc::precise_math::fmaxf(x, y); +} +__device__ float fminf(float x, float y) +{ + return hc::precise_math::fminf(x, y); +} +__device__ float fmodf(float x, float y) +{ + return hc::precise_math::fmodf(x, y); +} +__device__ float frexpf(float x, int *nptr) +{ + return hc::precise_math::frexpf(x, nptr); +} +__device__ float hypotf(float x, float y) +{ + return hc::precise_math::hypotf(x, y); +} +__device__ float ilogbf(float x) +{ + return hc::precise_math::ilogbf(x); +} +__device__ int isfinite(float a) +{ + return hc::precise_math::isfinite(a); +} +__device__ unsigned isinf(float a) +{ + return hc::precise_math::isinf(a); +} +__device__ unsigned isnan(float a) +{ + return hc::precise_math::isnan(a); +} +__device__ float j0f(float x) +{ + return __hip_j0f(x); +} +__device__ float j1f(float x) +{ + return __hip_j1f(x); +} +__device__ float jnf(int n, float x) +{ + return __hip_jnf(n, x); +} +__device__ float ldexpf(float x, int exp) +{ + return hc::precise_math::ldexpf(x, exp); +} +__device__ float lgammaf(float x) +{ + float val = 0.0f; + float y = x - 1; + while(y > 0){ + val += logf(y--); + } + return val; +} +__device__ long long int llrintf(float x) +{ + int y = hc::precise_math::roundf(x); + long long int z = y; + return z; +} +__device__ long long int llroundf(float x) +{ + int y = hc::precise_math::roundf(x); + long long int z = y; + return z; +} +__device__ float log10f(float x) +{ + return hc::precise_math::log10f(x); +} +__device__ float log1pf(float x) +{ + return hc::precise_math::log1pf(x); +} +__device__ float log2f(float x) +{ + return hc::precise_math::log2f(x); +} +__device__ float logbf(float x) +{ + return hc::precise_math::logbf(x); +} +__device__ float logf(float x) +{ + return hc::precise_math::logf(x); +} +__device__ long int lrintf(float x) +{ + int y = hc::precise_math::roundf(x); + long int z = y; + return z; +} +__device__ long int lroundf(float x) +{ + long int y = hc::precise_math::roundf(x); + return y; +} +__device__ float modff(float x, float *iptr) +{ + return hc::precise_math::modff(x, iptr); +} +__device__ float nanf(const char* tagp) +{ + return hc::precise_math::nanf((int)*tagp); +} +__device__ float nearbyintf(float x) +{ + return hc::precise_math::nearbyintf(x); +} +__device__ float nextafterf(float x, float y) +{ + return hc::precise_math::nextafter(x, y); +} +__device__ float norm3df(float a, float b, float c) +{ + float x = a*a + b*b + c*c; + return hc::precise_math::sqrtf(x); +} +__device__ float norm4df(float a, float b, float c, float d) +{ + float x = a*a + b*b; + float y = c*c + d*d; + return hc::precise_math::sqrtf(x+y); +} + +__device__ float normcdff(float y) +{ + return ((hc::precise_math::erff(y)/1.41421356237) + 1)/2; +} +__device__ float normcdfinvf(float y) +{ + return HIP_SQRT_2 * __hip_erfinvf(2*y-1); +} +__device__ float normf(int dim, const float *a) +{ + float x = 0.0f; + for(int i=0;i 0){ + val += log(y--); + } + return val; +} +__device__ long long int llrint(double x) +{ + long long int y = hc::precise_math::round(x); + return y; +} +__device__ long long int llround(double x) +{ + long long int y = hc::precise_math::round(x); + return y; +} +__device__ double log(double x) +{ + return hc::precise_math::log(x); +} +__device__ double log10(double x) +{ + return hc::precise_math::log10(x); +} +__device__ double log1p(double x) +{ + return hc::precise_math::log1p(x); +} +__device__ double log2(double x) +{ + return hc::precise_math::log2(x); +} +__device__ double logb(double x) +{ + return hc::precise_math::logb(x); +} +__device__ long int lrint(double x) +{ + long int y = hc::precise_math::round(x); + return y; +} +__device__ long int lround(double x) +{ + long int y = hc::precise_math::round(x); + return y; +} +__device__ double modf(double x, double *iptr) +{ + return hc::precise_math::modf(x, iptr); +} +__device__ double nan(const char *tagp) +{ + return hc::precise_math::nan((int)*tagp); +} +__device__ double nearbyint(double x) +{ + return hc::precise_math::nearbyint(x); +} +__device__ double nextafter(double x, double y) +{ + return hc::precise_math::nextafter(x, y); +} +__device__ double norm(int x, const double *d) +{ + double val = 0; + for(int i=0;i #include #include - //--- // Helper functions to convert HIP function arguments into strings. // Handles POD data types as well as enumerations (ie hipMemcpyKind). @@ -55,7 +54,7 @@ inline std::string ToHexString(T v) // This is the default which works for most types: template -inline std::string ToString(T v) +inline std::string ToString(T v) { std::ostringstream ss; ss << v; @@ -65,18 +64,15 @@ inline std::string ToString(T v) // hipEvent_t specialization. TODO - maybe add an event ID for debug? template <> -inline std::string ToString(hipEvent_t v) +inline std::string ToString(hipEvent_t v) { std::ostringstream ss; ss << v; return ss.str(); }; - - - // hipStream_t template <> -inline std::string ToString(hipStream_t v) +inline std::string ToString(hipStream_t v) { std::ostringstream ss; if (v == NULL) { @@ -90,7 +86,7 @@ inline std::string ToString(hipStream_t v) // hipMemcpyKind specialization template <> -inline std::string ToString(hipMemcpyKind v) +inline std::string ToString(hipMemcpyKind v) { switch(v) { CASE_STR(hipMemcpyHostToHost); @@ -104,14 +100,14 @@ inline std::string ToString(hipMemcpyKind v) template <> -inline std::string ToString(hipError_t v) +inline std::string ToString(hipError_t v) { return ihipErrorString(v); }; // Catch empty arguments case -inline std::string ToString() +inline std::string ToString() { return (""); } @@ -120,8 +116,8 @@ inline std::string ToString() //--- // C++11 variadic template - peels off first argument, converts to string, and calls itself again to peel the next arg. // Strings are automatically separated by comma+space. -template -inline std::string ToString(T first, Args... args) +template +inline std::string ToString(T first, Args... args) { return ToString(first) + ", " + ToString(args...) ; } diff --git a/projects/hip/tests/hit/HIT.cmake b/projects/hip/tests/hit/HIT.cmake index 0c8f7d39c3..fd0001214e 100644 --- a/projects/hip/tests/hit/HIT.cmake +++ b/projects/hip/tests/hit/HIT.cmake @@ -131,7 +131,7 @@ endmacro() # Macro: HIT_ADD_FILES used to scan+add multiple files for testing. file(GLOB HIP_LIB_FILES ${HIP_PATH}/lib/*) -macro(HIT_ADD_FILES _dir _label) +macro(HIT_ADD_FILES _dir _label _parent) foreach (file ${ARGN}) # Build tests execute_process(COMMAND ${HIP_SRC_PATH}/tests/hit/parser --buildCMDs ${file} @@ -148,8 +148,10 @@ macro(HIT_ADD_FILES _dir _label) if(_exclude_platforms STREQUAL "all" OR _exclude_platforms STREQUAL ${HIP_PLATFORM}) else() set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) - hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) + hip_reset_flags() + hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options} EXCLUDE_FROM_ALL) set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target} RUNTIME_OUTPUT_DIRECTORY ${_label} LINK_DEPENDS "${HIP_LIB_FILES}") + add_dependencies(${_parent} ${target}) endif() endforeach() @@ -196,24 +198,32 @@ endmacro() # Macro: HIT_ADD_DIRECTORY to scan+add all files in a directory for testing macro(HIT_ADD_DIRECTORY _dir _label) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + string(REGEX REPLACE "/" "." _parent ${_label}) + add_custom_target(${_parent}) file(GLOB files "${_dir}/*.c*") - hit_add_files(${_dir} ${_label} ${files}) + hit_add_files(${_dir} ${_label} ${parent} ${files}) endmacro() # Macro: HIT_ADD_DIRECTORY_RECURSIVE to scan+add all files in a directory+subdirectories for testing macro(HIT_ADD_DIRECTORY_RECURSIVE _dir _label) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + string(REGEX REPLACE "/" "." _parent ${_label}) + add_custom_target(${_parent}) + if(${ARGC} EQUAL 3) + add_dependencies(${ARGV2} ${_parent}) + endif() file(GLOB children RELATIVE ${_dir} ${_dir}/*) set(dirlist "") foreach(child ${children}) if(IS_DIRECTORY ${_dir}/${child}) list(APPEND dirlist ${child}) else() - hit_add_files(${_dir} ${_label} ${child}) + hit_add_files(${_dir} ${_label} ${_parent} ${child}) endif() endforeach() foreach(child ${dirlist}) - hit_add_directory_recursive(${_dir}/${child} ${_label}/${child}) + string(REGEX REPLACE "/" "." _parent ${_label}) + hit_add_directory_recursive(${_dir}/${child} ${_label}/${child} ${_parent}) endforeach() endmacro() diff --git a/projects/hip/tests/src/hipFuncDeviceSynchronize.cpp b/projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp similarity index 94% rename from projects/hip/tests/src/hipFuncDeviceSynchronize.cpp rename to projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp index 930bc37b8b..dac56bf709 100644 --- a/projects/hip/tests/src/hipFuncDeviceSynchronize.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -23,7 +23,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ @@ -63,13 +63,12 @@ int main(){ HIPCHECK(hipMemcpyAsync(A[i], Ad[i], _SIZE, hipMemcpyDeviceToHost, stream[i])); } - - // This first check but relies on the kernel running for so long that the D2H async memcopy has not started yet. - // This will be true in an optimal asynchronous implementation. + + // This first check but relies on the kernel running for so long that the D2H async memcopy has not started yet. + // This will be true in an optimal asynchronous implementation. // Conservative implementations which synchronize the hipMemcpyAsync will fail, ie if HIP_LAUNCH_BLOCKING=true HIPASSERT(1<<30 != A[NUM_STREAMS-1][0]-1); HIPCHECK(hipDeviceSynchronize()); HIPASSERT(1<<30 == A[NUM_STREAMS-1][0]-1); passed(); } - diff --git a/projects/hip/tests/src/hipFuncGetDevice.cpp b/projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp similarity index 93% rename from projects/hip/tests/src/hipFuncGetDevice.cpp rename to projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp index f903149f91..a268ec0acd 100644 --- a/projects/hip/tests/src/hipFuncGetDevice.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -23,7 +23,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipFuncSetDevice.cpp b/projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp similarity index 93% rename from projects/hip/tests/src/hipFuncSetDevice.cpp rename to projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp index 030ceb7b0c..b1b7cac12d 100644 --- a/projects/hip/tests/src/hipFuncSetDevice.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t EXCLUDE_HIP_PLATFORM * HIT_END */ diff --git a/projects/hip/tests/src/hipFuncSetDeviceFlags.cpp b/projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp similarity index 67% rename from projects/hip/tests/src/hipFuncSetDeviceFlags.cpp rename to projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp index 9bda91f113..eacd4d2b63 100644 --- a/projects/hip/tests/src/hipFuncSetDeviceFlags.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -8,17 +8,17 @@ 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 WARRANNTY OF ANY KIND, EXPRESS OR -IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +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. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipDeviceGetAttribute.cpp b/projects/hip/tests/src/Negative/Device/hipDeviceGetAttribute.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipDeviceGetAttribute.cpp rename to projects/hip/tests/src/Negative/Device/hipDeviceGetAttribute.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h b/projects/hip/tests/src/Negative/Device/hipDeviceUtil.h similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h rename to projects/hip/tests/src/Negative/Device/hipDeviceUtil.h diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDevice.cpp b/projects/hip/tests/src/Negative/Device/hipGetDevice.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDevice.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDevice.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceCount.cpp b/projects/hip/tests/src/Negative/Device/hipGetDeviceCount.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceCount.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDeviceCount.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceProperties.cpp b/projects/hip/tests/src/Negative/Device/hipGetDeviceProperties.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceProperties.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDeviceProperties.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp b/projects/hip/tests/src/Negative/Device/hipSetDevice.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp rename to projects/hip/tests/src/Negative/Device/hipSetDevice.cpp diff --git a/projects/hip/tests/src/hipPerfMemcpy.cpp b/projects/hip/tests/src/Performance/memory/hipPerfMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipPerfMemcpy.cpp rename to projects/hip/tests/src/Performance/memory/hipPerfMemcpy.cpp diff --git a/projects/hip/tests/src/buildHIPC.sh b/projects/hip/tests/src/buildHIPC.sh deleted file mode 100755 index b2c9ce2a07..0000000000 --- a/projects/hip/tests/src/buildHIPC.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -$HCC_HOME/bin/hcc -I$HCC_HOME/include -I$HSA_PATH/include -I$HIP_PATH/include -std=c11 -c hipC.c diff --git a/projects/hip/tests/src/context/hipCtx_simple.cpp b/projects/hip/tests/src/context/hipCtx_simple.cpp index bb2b32a56b..7bfd7d76d9 100644 --- a/projects/hip/tests/src/context/hipCtx_simple.cpp +++ b/projects/hip/tests/src/context/hipCtx_simple.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++ + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipDrvGetPCIBusId.cpp b/projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp similarity index 96% rename from projects/hip/tests/src/hipDrvGetPCIBusId.cpp rename to projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp index 21c49c194c..15c86b2214 100644 --- a/projects/hip/tests/src/hipDrvGetPCIBusId.cpp +++ b/projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp @@ -27,7 +27,8 @@ int main(){ hipInit(0); hipDevice_t device; hipDeviceGet(&device, 0); - char pciBusId[100]; + char pciBusId[10]; + memset(pciBusId,0,10); hipDeviceGetPCIBusId(pciBusId,100,device); printf("PCI Bus ID= %s\n",pciBusId); return 0; diff --git a/projects/hip/tests/src/hipDrvMemcpy.cpp b/projects/hip/tests/src/context/hipDrvMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipDrvMemcpy.cpp rename to projects/hip/tests/src/context/hipDrvMemcpy.cpp diff --git a/projects/hip/tests/src/context/hipMemsetD8.cpp b/projects/hip/tests/src/context/hipMemsetD8.cpp new file mode 100644 index 0000000000..3730fcb70b --- /dev/null +++ b/projects/hip/tests/src/context/hipMemsetD8.cpp @@ -0,0 +1,67 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ +// Simple test for hipMemsetD8. +// Also serves as a template for other tests. + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * //Small copy + * RUN: %t -N 10 --memsetval 0x42 + * // Oddball size + * RUN: %t -N 10013 --memsetval 0x5a + * // Big copy + * RUN: %t -N 256M --memsetval 0xa6 + * HIT_END + */ + +#include "hip/hip_runtime.h" +#include "test_common.h" + +int main(int argc, char *argv[]) +{ + HipTest::parseStandardArguments(argc, argv, true); + size_t Nbytes = N*sizeof(char); + char *A_h; + hipDeviceptr_t A_d; + A_h = new char[Nbytes]; + + HIPCHECK ( hipMalloc((void **) &A_d, Nbytes) ); + A_h = (char*)malloc(Nbytes); + + printf ("Size=%zu memsetval=%2x \n", Nbytes, memsetval); + HIPCHECK ( hipMemsetD8(A_d, memsetval, Nbytes) ); + + HIPCHECK ( hipMemcpy(A_h, (void *) A_d, Nbytes, hipMemcpyDeviceToHost)); + + for (int i=0; i +#include #include "hip/hip_runtime.h" #include "hip/hip_runtime_api.h" +#include "../test_common.h" + #define LEN 1030 #define SIZE LEN << 2 -__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In, uint32_t *Vald) +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + + +__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In) { - memcpy(Out, In, SIZE, Vald); + int tx = hipThreadIdx_x; + memcpy(Out + tx, In + tx, SIZE/LEN); } __global__ void set(hipLaunchParm lp, uint32_t *ptr, uint8_t val, size_t size) { - memset(ptr, val, size); + int tx = hipThreadIdx_x; + memset(ptr + tx, val, size); } int main() @@ -24,19 +35,29 @@ int main() Val = new uint32_t; *Val = 0; for(int i=0;i +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -27,18 +35,18 @@ THE SOFTWARE. __device__ void double_precision_intrinsics() { - //__dadd_rd(0.0, 1.0); - //__dadd_rn(0.0, 1.0); - //__dadd_ru(0.0, 1.0); - //__dadd_rz(0.0, 1.0); - //__ddiv_rd(0.0, 1.0); - //__ddiv_rn(0.0, 1.0); - //__ddiv_ru(0.0, 1.0); - //__ddiv_rz(0.0, 1.0); - //__dmul_rd(1.0, 2.0); - //__dmul_rn(1.0, 2.0); - //__dmul_ru(1.0, 2.0); - //__dmul_rz(1.0, 2.0); + __dadd_rd(0.0, 1.0); + __dadd_rn(0.0, 1.0); + __dadd_ru(0.0, 1.0); + __dadd_rz(0.0, 1.0); + __ddiv_rd(0.0, 1.0); + __ddiv_rn(0.0, 1.0); + __ddiv_ru(0.0, 1.0); + __ddiv_rz(0.0, 1.0); + __dmul_rd(1.0, 2.0); + __dmul_rn(1.0, 2.0); + __dmul_ru(1.0, 2.0); + __dmul_rz(1.0, 2.0); __drcp_rd(2.0); __drcp_rn(2.0); __drcp_ru(2.0); @@ -47,10 +55,10 @@ __device__ void double_precision_intrinsics() __dsqrt_rn(4.0); __dsqrt_ru(4.0); __dsqrt_rz(4.0); - //__dsub_rd(2.0, 1.0); - //__dsub_rn(2.0, 1.0); - //__dsub_ru(2.0, 1.0); - //__dsub_rz(2.0, 1.0); + __dsub_rd(2.0, 1.0); + __dsub_rn(2.0, 1.0); + __dsub_ru(2.0, 1.0); + __dsub_rz(2.0, 1.0); __fma_rd(1.0, 2.0, 3.0); __fma_rn(1.0, 2.0, 3.0); __fma_ru(1.0, 2.0, 3.0); @@ -61,3 +69,9 @@ __global__ void compileDoublePrecisionIntrinsics(hipLaunchParm lp, int ignored) { double_precision_intrinsics(); } + +int main() +{ + hipLaunchKernel(compileDoublePrecisionIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp index 996577e840..df5dad3968 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp @@ -19,7 +19,15 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -43,8 +51,8 @@ __device__ void double_precision_math_functions() cos(0.0); cosh(0.0); cospi(0.0); - //cyl_bessel_i0(0.0); - //cyl_bessel_i1(0.0); +// cyl_bessel_i0(0.0); +// cyl_bessel_i1(0.0); erf(0.0); erfc(0.0); erfcinv(2.0); @@ -61,7 +69,7 @@ __device__ void double_precision_math_functions() fmax(0.0, 0.0); fmin(0.0, 0.0); fmod(0.0, 1.0); - //frexp(0.0, &iX); +// frexp(0.0, &iX); hypot(1.0, 0.0); ilogb(1.0); isfinite(0.0); @@ -71,7 +79,7 @@ __device__ void double_precision_math_functions() j1(0.0); jn(-1.0, 1.0); ldexp(0.0, 0); - //lgamma(1.0); +// lgamma(1.0); llrint(0.0); llround(0.0); log(1.0); @@ -81,19 +89,19 @@ __device__ void double_precision_math_functions() logb(1.0); lrint(0.0); lround(0.0); - //modf(0.0, &fX); +// modf(0.0, &fX); nan("1"); nearbyint(0.0); - //nextafter(0.0); - //fX = 1.0; norm(1, &fX); + nextafter(0.0, 0.0); + fX = 1.0; norm(1, &fX); norm3d(1.0, 0.0, 0.0); norm4d(1.0, 0.0, 0.0, 0.0); normcdf(0.0); - //normcdfinv(1.0); + normcdfinv(1.0); pow(1.0, 0.0); rcbrt(1.0); remainder(2.0, 1.0); - //remquo(1.0, 2.0, &iX); +// remquo(1.0, 2.0, &iX); rhypot(0.0, 1.0); rint(1.0); fX = 1.0; rnorm(1, &fX); @@ -123,3 +131,9 @@ __global__ void compileDoublePrecisionMathOnDevice(hipLaunchParm lp, int ignored { double_precision_math_functions(); } + +int main() +{ + hipLaunchKernel(compileDoublePrecisionMathOnDevice, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 9980dad277..33f4010a2b 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -19,8 +19,17 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -42,14 +51,14 @@ __host__ void double_precision_math_functions() copysign(1.0, -2.0); cos(0.0); cosh(0.0); - cospi(0.0); + //cospi(0.0); //cyl_bessel_i0(0.0); //cyl_bessel_i1(0.0); erf(0.0); erfc(0.0); - erfcinv(2.0); - erfcx(0.0); - erfinv(1.0); + //erfcinv(2.0); + //erfcx(0.0); + //erfinv(1.0); exp(0.0); exp10(0.0); exp2(0.0); @@ -64,14 +73,14 @@ __host__ void double_precision_math_functions() frexp(0.0, &iX); hypot(1.0, 0.0); ilogb(1.0); - isfinite(0.0); - isinf(0.0); - isnan(0.0); + std::isfinite(0.0); + std::isinf(0.0); + std::isnan(0.0); j0(0.0); j1(0.0); jn(-1.0, 1.0); ldexp(0.0, 0); - lgamma(1.0); +// lgamma(1.0); llrint(0.0); llround(0.0); log(1.0); @@ -85,36 +94,37 @@ __host__ void double_precision_math_functions() nan("1"); nearbyint(0.0); //nextafter(0.0); - //fX = 1.0; norm(1, &fX); + fX = 1.0; //norm(1, &fX); #if defined(__HIP_PLATFORM_HCC__) - norm3d(1.0, 0.0, 0.0); - norm4d(1.0, 0.0, 0.0, 0.0); + //norm3d(1.0, 0.0, 0.0); + //norm4d(1.0, 0.0, 0.0, 0.0); #endif - normcdf(0.0); - normcdfinv(1.0); +// normcdf(0.0); +// normcdfinv(1.0); pow(1.0, 0.0); - rcbrt(1.0); + //rcbrt(1.0); + remainder(2.0, 1.0); remquo(1.0, 2.0, &iX); #if defined(__HIP_PLATFORM_HCC__) - rhypot(0.0, 1.0); + //rhypot(0.0, 1.0); #endif rint(1.0); #if defined(__HIP_PLATFORM_HCC__) - fX = 1.0; rnorm(1, &fX); - rnorm3d(0.0, 0.0, 1.0); - rnorm4d(0.0, 0.0, 0.0, 1.0); + fX = 1.0; //rnorm(1, &fX); + //rnorm3d(0.0, 0.0, 1.0); + //rnorm4d(0.0, 0.0, 0.0, 1.0); #endif round(0.0); - rsqrt(1.0); + //rsqrt(1.0); scalbln(0.0, 1); scalbn(0.0, 1); - signbit(1.0); + std::signbit(1.0); sin(0.0); sincos(0.0, &fX, &fY); - sincospi(0.0, &fX, &fY); + //sincospi(0.0, &fX, &fY); sinh(0.0); - sinpi(0.0); + //sinpi(0.0); sqrt(0.0); tan(0.0); tanh(0.0); @@ -129,3 +139,9 @@ static void compileOnHost() { double_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipFloatMath.cpp b/projects/hip/tests/src/deviceLib/hipFloatMath.cpp index f137ca2602..7a96b5cd0d 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMath.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMath.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. */ #include "test_common.h" +#include #define LEN 512 #define SIZE LEN<<2 diff --git a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp index 4f6c2cd44a..78fe47cfe8 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp @@ -19,7 +19,15 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include #include "test_common.h" __global__ void FloatMathPrecise(hipLaunchParm lp) @@ -119,4 +127,5 @@ __global__ void FloatMathPrecise(hipLaunchParm lp) int main() { hipLaunchKernel(FloatMathPrecise, dim3(1,1,1), dim3(1,1,1), 0, 0); + passed(); } diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index abe0b66e90..27af03ced3 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,7 +19,16 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + + +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -29,30 +38,38 @@ __device__ void integer_intrinsics() { __brev((unsigned int)10); __brevll((unsigned long long)10); - //__byte_perm((unsigned int)0, (unsigned int)0, 0); + __byte_perm((unsigned int)0, (unsigned int)0, 0); __clz((int)10); __clzll((long long)10); __ffs((int)10); __ffsll((long long)10); - //__hadd((int)1, (int)3); + __hadd((int)1, (int)3); __mul24((int)1, (int)2); - //__mul64hi((long long)1, (long long)2); - //__mulhi((int)1, (int)2); + __mul64hi((long long)1, (long long)2); + __mulhi((int)1, (int)2); __popc((unsigned int)4); __popcll((unsigned long long)4); int a = min((int)4, (int)5); int b = max((int)4, (int)5); - //__rhadd((int)1, (int)2); - //__sad((int)1, (int)2, 0); - //__uhadd((unsigned int)1, (unsigned int)3); + __rhadd((int)1, (int)2); + __sad((int)1, (int)2, 0); + __uhadd((unsigned int)1, (unsigned int)3); __umul24((unsigned int)1, (unsigned int)2); - //__umul64hi((unsigned long long)1, (unsigned long long)2); - //__umulhi((unsigned int)1, (unsigned int)2); - //__urhadd((unsigned int)1, (unsigned int)2); - //__usad((unsigned int)1, (unsigned int)2, 0); + __umul64hi((unsigned long long)1, (unsigned long long)2); + __umulhi((unsigned int)1, (unsigned int)2); + __urhadd((unsigned int)1, (unsigned int)2); + __usad((unsigned int)1, (unsigned int)2, 0); + + assert(1); } __global__ void compileIntegerIntrinsics(hipLaunchParm lp, int ignored) { integer_intrinsics(); } + +int main() +{ + hipLaunchKernel(compileIntegerIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp b/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp index ed62120613..450b6126b0 100644 --- a/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp +++ b/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp @@ -20,15 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* HIT_START - * BUILD: %tHost %s hipSinglePrecisionMathHost.cpp hipDoublePrecisionMathHost.cpp ../test_common.cpp - * BUILD: %tDevice %s hipSinglePrecisionMathDevice.cpp hipDoublePrecisionMathDevice.cpp ../test_common.cpp - * BUILD: hipIntrinsics %s hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp ../test_common.cpp - * RUN: %tHost - * RUN: %tDevice - * RUN: hipIntrinsics - * HIT_END - */ #include "hip/hip_runtime.h" #include "test_common.h" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp index caddcc0149..3407748437 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp @@ -19,7 +19,14 @@ 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. */ -#include "hip/hip_runtime.h" +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -30,44 +37,44 @@ __device__ void single_precision_intrinsics() float fX, fY; __cosf(0.0f); - //__exp10f(0.0f); + __exp10f(0.0f); __expf(0.0f); - //__fadd_rd(0.0f, 1.0f); - //__fadd_rn(0.0f, 1.0f); - //__fadd_ru(0.0f, 1.0f); - //__fadd_rz(0.0f, 1.0f); - //__fdiv_rd(4.0f, 2.0f); - //__fdiv_rn(4.0f, 2.0f); - //__fdiv_ru(4.0f, 2.0f); - //__fdiv_rz(4.0f, 2.0f); - //__fdividef(4.0f, 2.0f); - //__fmaf_rd(1.0f, 2.0f, 3.0f); - //__fmaf_rn(1.0f, 2.0f, 3.0f); - //__fmaf_ru(1.0f, 2.0f, 3.0f); - //__fmaf_rz(1.0f, 2.0f, 3.0f); - //__fmul_rd(1.0f, 2.0f); - //__fmul_rn(1.0f, 2.0f); - //__fmul_ru(1.0f, 2.0f); - //__fmul_rz(1.0f, 2.0f); - //__frcp_rd(2.0f); - //__frcp_rn(2.0f); - //__frcp_ru(2.0f); - //__frcp_rz(2.0f); + __fadd_rd(0.0f, 1.0f); + __fadd_rn(0.0f, 1.0f); + __fadd_ru(0.0f, 1.0f); + __fadd_rz(0.0f, 1.0f); + __fdiv_rd(4.0f, 2.0f); + __fdiv_rn(4.0f, 2.0f); + __fdiv_ru(4.0f, 2.0f); + __fdiv_rz(4.0f, 2.0f); + __fdividef(4.0f, 2.0f); + __fmaf_rd(1.0f, 2.0f, 3.0f); + __fmaf_rn(1.0f, 2.0f, 3.0f); + __fmaf_ru(1.0f, 2.0f, 3.0f); + __fmaf_rz(1.0f, 2.0f, 3.0f); + __fmul_rd(1.0f, 2.0f); + __fmul_rn(1.0f, 2.0f); + __fmul_ru(1.0f, 2.0f); + __fmul_rz(1.0f, 2.0f); + __frcp_rd(2.0f); + __frcp_rn(2.0f); + __frcp_ru(2.0f); + __frcp_rz(2.0f); __frsqrt_rn(4.0f); __fsqrt_rd(4.0f); __fsqrt_rn(4.0f); __fsqrt_ru(4.0f); __fsqrt_rz(4.0f); - //__fsub_rd(2.0f, 1.0f); - //__fsub_rn(2.0f, 1.0f); - //__fsub_ru(2.0f, 1.0f); - //__fsub_rz(2.0f, 1.0f); + __fsub_rd(2.0f, 1.0f); + __fsub_rn(2.0f, 1.0f); + __fsub_ru(2.0f, 1.0f); + __fsub_rz(2.0f, 1.0f); __log10f(1.0f); __log2f(1.0f); __logf(1.0f); __powf(1.0f, 0.0f); - //__saturatef(0.1f); - //__sincosf(0.0f, &fX, &fY); + __saturatef(0.1f); + __sincosf(0.0f, &fX, &fY); __sinf(0.0f); __tanf(0.0f); } @@ -77,3 +84,10 @@ __global__ void compileSinglePrecisionIntrinsics(hipLaunchParm lp, int ignored) { single_precision_intrinsics(); } + + +int main() +{ + hipLaunchKernel(compileSinglePrecisionIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp index a8c1194aab..53ccd2251f 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp @@ -19,7 +19,15 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -124,3 +132,9 @@ __global__ void compileSinglePrecisionMathOnDevice(hipLaunchParm lp, int ignored { single_precision_math_functions(); } + +int main() +{ + hipLaunchKernel(compileSinglePrecisionMathOnDevice, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 36aa852d81..cc554a5c36 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -19,8 +19,17 @@ 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. */ -#include "hip/hip_runtime.h" + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -42,14 +51,14 @@ __host__ void single_precision_math_functions() copysignf(1.0f, -2.0f); cosf(0.0f); coshf(0.0f); - cospif(0.0f); + //cospif(0.0f); //cyl_bessel_i0f(0.0f); //cyl_bessel_i1f(0.0f); erfcf(0.0f); - erfcinvf(2.0f); - erfcxf(0.0f); + //erfcinvf(2.0f); + //erfcxf(0.0f); erff(0.0f); - erfinvf(1.0f); + //erfinvf(1.0f); exp10f(0.0f); exp2f(0.0f); expf(0.0f); @@ -57,7 +66,7 @@ __host__ void single_precision_math_functions() fabsf(1.0f); fdimf(1.0f, 0.0f); #if defined(__HIP_PLATFORM_HCC__) - fdividef(0.0f, 1.0f); + //fdividef(0.0f, 1.0f); #endif floorf(0.0f); fmaf(1.0f, 2.0f, 3.0f); @@ -67,9 +76,9 @@ __host__ void single_precision_math_functions() frexpf(0.0f, &iX); hypotf(1.0f, 0.0f); ilogbf(1.0f); - isfinite(0.0f); - isinf(0.0f); - isnan(0.0f); + std::isfinite(0.0f); + std::isinf(0.0f); + std::isnan(0.0f); j0f(0.0f); j1f(0.0f); jnf(-1.0f, 1.0f); @@ -89,35 +98,35 @@ __host__ void single_precision_math_functions() nearbyintf(0.0f); //nextafterf(0.0f); #if defined(__HIP_PLATFORM_HCC__) - norm3df(1.0f, 0.0f, 0.0f); - norm4df(1.0f, 0.0f, 0.0f, 0.0f); + //norm3df(1.0f, 0.0f, 0.0f); + //norm4df(1.0f, 0.0f, 0.0f, 0.0f); #endif - normcdff(0.0f); - normcdfinvf(1.0f); + //normcdff(0.0f); + //normcdfinvf(1.0f); //fX = 1.0f; normf(1, &fX); powf(1.0f, 0.0f); - rcbrtf(1.0f); + //rcbrtf(1.0f); remainderf(2.0f, 1.0f); remquof(1.0f, 2.0f, &iX); #if defined(__HIP_PLATFORM_HCC__) - rhypotf(0.0f, 1.0f); + //rhypotf(0.0f, 1.0f); #endif rintf(1.0f); #if defined(__HIP_PLATFORM_HCC__) - rnorm3df(0.0f, 0.0f, 1.0f); - rnorm4df(0.0f, 0.0f, 0.0f, 1.0f); - fX = 1.0f; rnormf(1, &fX); + //rnorm3df(0.0f, 0.0f, 1.0f); + //rnorm4df(0.0f, 0.0f, 0.0f, 1.0f); + fX = 1.0f; //rnormf(1, &fX); #endif roundf(0.0f); - rsqrtf(1.0f); + ///rsqrtf(1.0f); scalblnf(0.0f, 1); scalbnf(0.0f, 1); - signbit(1.0f); + std::signbit(1.0f); sincosf(0.0f, &fX, &fY); - sincospif(0.0f, &fX, &fY); + //sincospif(0.0f, &fX, &fY); sinf(0.0f); sinhf(0.0f); - sinpif(0.0f); + //sinpif(0.0f); sqrtf(0.0f); tanf(0.0f); tanhf(0.0f); @@ -132,3 +141,9 @@ static void compileOnHost() { single_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp index 9d90eb7de0..570f3baaf0 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp @@ -24,8 +24,9 @@ THE SOFTWARE. */ #include"test_common.h" -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" +#include +#include +#include #define N 512 #define SIZE N*sizeof(float) @@ -163,13 +164,13 @@ hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost); hipMemcpy(C, Cd, SIZE, hipMemcpyDeviceToHost); int passed = 0; for(int i=0;i<512;i++){ - if(B[i] - sinpif(1.0f) < 0.1){ + if(B[i] - sinf(3.14*1.0f) < 0.1){ passed = 1; } } passed = 0; for(int i=0;i<512;i++){ - if(C[i] - cospif(1.0f) < 0.1){ + if(C[i] - cosf(3.14*1.0f) < 0.1){ passed = 1; } } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp index c401a44cbd..5bdbbf1b8f 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp @@ -24,8 +24,9 @@ THE SOFTWARE. */ #include"test_common.h" -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" +#include +#include +#include #define N 512 #define SIZE N*sizeof(double) @@ -152,13 +153,13 @@ hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost); hipMemcpy(C, Cd, SIZE, hipMemcpyDeviceToHost); int passed = 0; for(int i=0;i<512;i++){ - if(B[i] - sinpi(1.0) < 0.1){ + if(B[i] - sin(3.14*1.0) < 0.1){ passed = 1; } } passed = 0; for(int i=0;i<512;i++){ - if(C[i] - cospi(1.0) < 0.1){ + if(C[i] - cos(3.14*1.0) < 0.1){ passed = 1; } } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 1158bf3f9d..c2ffb5ce7d 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -17,48 +17,69 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s EXCLUDE_HIP_PLATFORM all + * RUN: %t + * HIT_END + */ + #include #include +#include"test_common.h" #include #define NUM 1024 #define SIZE 1024*4 +// TODO - collapse: #ifdef __HIP_PLATFORM_HCC__ -__attribute__((address_space(1))) int global[NUM]; +__device__ ADDRESS_SPACE_1 int globalIn[NUM]; +__device__ ADDRESS_SPACE_1 int globalOut[NUM]; #endif #ifdef __HIP_PLATFORM_NVCC__ -__device__ int global[NUM]; +__device__ int globalIn[NUM]; +__device__ int globalOut[NUM]; #endif __global__ void Assign(hipLaunchParm lp, int* Out) { int tid = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; - Out[tid] = global[tid]; + Out[tid] = globalIn[tid]; + globalOut[tid] = globalIn[tid]; } int main() { - int *A, *B, *Ad; + int *A, *Am, *B, *Ad, *C, *Cm; A = new int[NUM]; B = new int[NUM]; + C = new int[NUM]; for(unsigned i=0;i +#include +#include "hip/hip_runtime_api.h" + +#define LEN 64 +#define HALF_SIZE 64*sizeof(__half) +#define HALF2_SIZE 64*sizeof(__half2) + +#if __HIP_ARCH_GFX803__ > 0 + +__global__ void __halfMath(hipLaunchParm lp, __half *A, __half *B, __half *C) { + int tx = hipThreadIdx_x; + __half a = A[tx]; + __half b = B[tx]; + __half c = C[tx]; + c = __hadd(a, c); + c = __hadd_sat(b, c); + c = __hfma(a, c, b); + c = __hfma_sat(b, c, a); + c = __hsub(a, c); + c = __hsub_sat(b, c); + c = __hmul(a, c); + c = __hmul_sat(b, c); + c = hdiv(a, c); +} + +__global__ void __half2Math(hipLaunchParm lp, __half2 *A, __half2 *B, __half2 *C) { + int tx = hipThreadIdx_x; + __half2 a = A[tx]; + __half2 b = B[tx]; + __half2 c = C[tx]; + c = __hadd2(a, c); + c = __hadd2_sat(b, c); + c = __hfma2(a, c, b); + c = __hfma2_sat(b, c, a); + c = __hsub2(a, c); + c = __hsub2_sat(b, c); + c = __hmul2(a, c); + c = __hmul2_sat(b, c); +} + +#endif + +int main(){ + __half *A, *B, *C; + hipMalloc(&A, HALF_SIZE); + hipMalloc(&B, HALF_SIZE); + hipMalloc(&C, HALF_SIZE); + hipLaunchKernel(__halfMath, dim3(1,1,1), dim3(LEN,1,1), 0, 0, A, B, C); + __half2 *A2, *B2, *C2; + hipMalloc(&A, HALF2_SIZE); + hipMalloc(&B, HALF2_SIZE); + hipMalloc(&C, HALF2_SIZE); + hipLaunchKernel(__half2Math, dim3(1,1,1), dim3(LEN,1,1), 0, 0, A2, B2, C2); + +} diff --git a/projects/hip/tests/src/hipTestHost.cpp b/projects/hip/tests/src/deviceLib/hipTestHost.cpp similarity index 100% rename from projects/hip/tests/src/hipTestHost.cpp rename to projects/hip/tests/src/deviceLib/hipTestHost.cpp diff --git a/projects/hip/tests/src/deviceLib/hipThreadFence.cpp b/projects/hip/tests/src/deviceLib/hipThreadFence.cpp index e73ccf6ad3..1bd9fbe02c 100644 --- a/projects/hip/tests/src/deviceLib/hipThreadFence.cpp +++ b/projects/hip/tests/src/deviceLib/hipThreadFence.cpp @@ -17,9 +17,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include +#include"test_common.h" #define NUM 1024 #define SIZE NUM*sizeof(float) @@ -65,5 +72,5 @@ int main(){ hipLaunchKernel(vAdd, dim3(32,1,1), dim3(32,1,1), 0, 0, In1d, In2d, In3d, In4d, Outd); hipMemcpy(Out, Outd, SIZE, hipMemcpyDeviceToHost); assert(Out[10] == 2*In1[10] + 2*In2[10] + In3[10]); - + passed(); } diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp new file mode 100644 index 0000000000..9dd0793c98 --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -0,0 +1,7838 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc + * RUN: %t + * HIT_END + */ + +#include +#include +#include +#include"test_common.h" +#define cmpVal1(in, exp) \ + if(in.x != exp) { \ + std::cout<<"Failed at: "<<__LINE__<<" in func: "<<__func__<<" expected output: "<> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 253); + assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + uchar1 fa((unsigned char)1); + uchar1 fb((signed char)1); + uchar1 fc((unsigned short)1); + uchar1 fd((signed short)1); + uchar1 fe((unsigned int)1); + uchar1 fg((signed int)1); + uchar1 fh((float)1); + uchar1 fi((double)1); + uchar1 fj((unsigned long)1); + uchar1 fk((signed long)1); + uchar1 fl((unsigned long long)1); + uchar1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar2() { + uchar2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + uchar2 fa1((unsigned char)1); + uchar2 fa2((unsigned char)1, (unsigned char)1); + uchar2 fb1((signed char)1); + uchar2 fb2((signed char)1, (signed char)1); + uchar2 fc1((unsigned short)1); + uchar2 fc2((unsigned short)1,(unsigned short)1); + uchar2 fd1((signed short)1); + uchar2 fd2((signed short)1, (signed short)1); + uchar2 fe1((unsigned int)1); + uchar2 fe2((unsigned int)1, (unsigned int)1); + uchar2 fg1((signed int)1); + uchar2 fg2((signed int)1, (signed int)1); + uchar2 fh1((float)1); + uchar2 fh2((float)1, (float)1); + uchar2 fi1((double)1); + uchar2 fi2((double)1, (double)1); + uchar2 fj1((unsigned long)1); + uchar2 fj2((unsigned long)1, (unsigned long)1); + uchar2 fk1((signed long)1); + uchar2 fk2((signed long)1, (signed long)1); + uchar2 fl1((unsigned long long)1); + uchar2 fl2((unsigned long long)1, (unsigned long long)1); + uchar2 fm1((signed long long)1); + uchar2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar3() { + uchar3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + uchar3 fa1((unsigned char)1); + uchar3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + uchar3 fb1((signed char)1); + uchar3 fb2((signed char)1, (signed char)1, (signed char)1); + uchar3 fc1((unsigned short)1); + uchar3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + uchar3 fd1((signed short)1); + uchar3 fd2((signed short)1, (signed short)1, (signed short)1); + uchar3 fe1((unsigned int)1); + uchar3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + uchar3 fg1((signed int)1); + uchar3 fg2((signed int)1, (signed int)1, (signed int)1); + uchar3 fh1((float)1); + uchar3 fh2((float)1, (float)1, (float)1); + uchar3 fi1((double)1); + uchar3 fi2((double)1, (double)1, (double)1); + uchar3 fj1((unsigned long)1); + uchar3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + uchar3 fk1((signed long)1); + uchar3 fk2((signed long)1, (signed long)1, (signed long)1); + uchar3 fl1((unsigned long long)1); + uchar3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uchar3 fm1((signed long long)1); + uchar3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar4() { + uchar4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + + uchar4 fa1((unsigned char)1); + uchar4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + uchar4 fb1((signed char)1); + uchar4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + uchar4 fc1((unsigned short)1); + uchar4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + uchar4 fd1((signed short)1); + uchar4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + uchar4 fe1((unsigned int)1); + uchar4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + uchar4 fg1((signed int)1); + uchar4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + uchar4 fh1((float)1); + uchar4 fh2((float)1, (float)1, (float)1, (float)1); + uchar4 fi1((double)1); + uchar4 fi2((double)1, (double)1, (double)1, (double)1); + uchar4 fj1((unsigned long)1); + uchar4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + uchar4 fk1((signed long)1); + uchar4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + uchar4 fl1((unsigned long long)1); + uchar4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uchar4 fm1((signed long long)1); + uchar4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestChar1() { + char1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + char1 fa((unsigned char)1); + char1 fb((signed char)1); + char1 fc((unsigned short)1); + char1 fd((signed short)1); + char1 fe((unsigned int)1); + char1 fg((signed int)1); + char1 fh((float)1); + char1 fi((double)1); + char1 fj((unsigned long)1); + char1 fk((signed long)1); + char1 fl((unsigned long long)1); + char1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar2() { + char2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + char2 fa1((unsigned char)1); + char2 fa2((unsigned char)1, (unsigned char)1); + char2 fb1((signed char)1); + char2 fb2((signed char)1, (signed char)1); + char2 fc1((unsigned short)1); + char2 fc2((unsigned short)1,(unsigned short)1); + char2 fd1((signed short)1); + char2 fd2((signed short)1, (signed short)1); + char2 fe1((unsigned int)1); + char2 fe2((unsigned int)1, (unsigned int)1); + char2 fg1((signed int)1); + char2 fg2((signed int)1, (signed int)1); + char2 fh1((float)1); + char2 fh2((float)1, (float)1); + char2 fi1((double)1); + char2 fi2((double)1, (double)1); + char2 fj1((unsigned long)1); + char2 fj2((unsigned long)1, (unsigned long)1); + char2 fk1((signed long)1); + char2 fk2((signed long)1, (signed long)1); + char2 fl1((unsigned long long)1); + char2 fl2((unsigned long long)1, (unsigned long long)1); + char2 fm1((signed long long)1); + char2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar3() { + char3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + char3 fa1((unsigned char)1); + char3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + char3 fb1((signed char)1); + char3 fb2((signed char)1, (signed char)1, (signed char)1); + char3 fc1((unsigned short)1); + char3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + char3 fd1((signed short)1); + char3 fd2((signed short)1, (signed short)1, (signed short)1); + char3 fe1((unsigned int)1); + char3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + char3 fg1((signed int)1); + char3 fg2((signed int)1, (signed int)1, (signed int)1); + char3 fh1((float)1); + char3 fh2((float)1, (float)1, (float)1); + char3 fi1((double)1); + char3 fi2((double)1, (double)1, (double)1); + char3 fj1((unsigned long)1); + char3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + char3 fk1((signed long)1); + char3 fk2((signed long)1, (signed long)1, (signed long)1); + char3 fl1((unsigned long long)1); + char3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + char3 fm1((signed long long)1); + char3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar4() { + char4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + char4 fa1((unsigned char)1); + char4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + char4 fb1((signed char)1); + char4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + char4 fc1((unsigned short)1); + char4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + char4 fd1((signed short)1); + char4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + char4 fe1((unsigned int)1); + char4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + char4 fg1((signed int)1); + char4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + char4 fh1((float)1); + char4 fh2((float)1, (float)1, (float)1, (float)1); + char4 fi1((double)1); + char4 fi2((double)1, (double)1, (double)1, (double)1); + char4 fj1((unsigned long)1); + char4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + char4 fk1((signed long)1); + char4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + char4 fl1((unsigned long long)1); + char4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + char4 fm1((signed long long)1); + char4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestUShort1() { + ushort1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ushort1 fa((unsigned char)1); + ushort1 fb((signed char)1); + ushort1 fc((unsigned short)1); + ushort1 fd((signed short)1); + ushort1 fe((unsigned int)1); + ushort1 fg((signed int)1); + ushort1 fh((float)1); + ushort1 fi((double)1); + ushort1 fj((unsigned long)1); + ushort1 fk((signed long)1); + ushort1 fl((unsigned long long)1); + ushort1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort2() { + ushort2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ushort2 fa1((unsigned char)1); + ushort2 fa2((unsigned char)1, (unsigned char)1); + ushort2 fb1((signed char)1); + ushort2 fb2((signed char)1, (signed char)1); + ushort2 fc1((unsigned short)1); + ushort2 fc2((unsigned short)1, (unsigned short)1); + ushort2 fd1((signed short)1); + ushort2 fd2((signed short)1, (signed short)1); + ushort2 fe1((unsigned int)1); + ushort2 fe2((unsigned int)1, (unsigned int)1); + ushort2 fg1((signed int)1); + ushort2 fg2((signed int)1, (signed int)1); + ushort2 fh1((float)1); + ushort2 fh2((float)1, (float)1); + ushort2 fi1((double)1); + ushort2 fi2((double)1, (double)1); + ushort2 fj1((unsigned long)1); + ushort2 fj2((unsigned long)1, (unsigned long)1); + ushort2 fk1((signed long)1); + ushort2 fk2((signed long)1, (signed long)1); + ushort2 fl1((unsigned long long)1); + ushort2 fl2((unsigned long long)1, (unsigned long long)1); + ushort2 fm1((signed long long)1); + ushort2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort3() { + ushort3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ushort3 fa1((unsigned char)1); + ushort3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ushort3 fb1((signed char)1); + ushort3 fb2((signed char)1, (signed char)1, (signed char)1); + ushort3 fc1((unsigned short)1); + ushort3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ushort3 fd1((signed short)1); + ushort3 fd2((signed short)1, (signed short)1, (signed short)1); + ushort3 fe1((unsigned int)1); + ushort3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ushort3 fg1((signed int)1); + ushort3 fg2((signed int)1, (signed int)1, (signed int)1); + ushort3 fh1((float)1); + ushort3 fh2((float)1, (float)1, (float)1); + ushort3 fi1((double)1); + ushort3 fi2((double)1, (double)1, (double)1); + ushort3 fj1((unsigned long)1); + ushort3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ushort3 fk1((signed long)1); + ushort3 fk2((signed long)1, (signed long)1, (signed long)1); + ushort3 fl1((unsigned long long)1); + ushort3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ushort3 fm1((signed long long)1); + ushort3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort4() { + ushort4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ushort4 fa1((unsigned char)1); + ushort4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ushort4 fb1((signed char)1); + ushort4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ushort4 fc1((unsigned short)1); + ushort4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ushort4 fd1((signed short)1); + ushort4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ushort4 fe1((unsigned int)1); + ushort4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ushort4 fg1((signed int)1); + ushort4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ushort4 fh1((float)1); + ushort4 fh2((float)1, (float)1, (float)1, (float)1); + ushort4 fi1((double)1); + ushort4 fi2((double)1, (double)1, (double)1, (double)1); + ushort4 fj1((unsigned long)1); + ushort4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ushort4 fk1((signed long)1); + ushort4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ushort4 fl1((unsigned long long)1); + ushort4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ushort4 fm1((signed long long)1); + ushort4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestShort1() { + short1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + short1 fa((unsigned char)1); + short1 fb((signed char)1); + short1 fc((unsigned short)1); + short1 fd((signed short)1); + short1 fe((unsigned int)1); + short1 fg((signed int)1); + short1 fh((float)1); + short1 fi((double)1); + short1 fj((unsigned long)1); + short1 fk((signed long)1); + short1 fl((unsigned long long)1); + short1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort2() { + short2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed short)65533); + assert(!f1 == false); + + cmpVal2(f1, 3); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + short2 fa1((unsigned char)1); + short2 fa2((unsigned char)1, (unsigned char)1); + short2 fb1((signed char)1); + short2 fb2((signed char)1, (signed char)1); + short2 fc1((unsigned short)1); + short2 fc2((unsigned short)1,(unsigned short)1); + short2 fd1((signed short)1); + short2 fd2((signed short)1, (signed short)1); + short2 fe1((unsigned int)1); + short2 fe2((unsigned int)1, (unsigned int)1); + short2 fg1((signed int)1); + short2 fg2((signed int)1, (signed int)1); + short2 fh1((float)1); + short2 fh2((float)1, (float)1); + short2 fi1((double)1); + short2 fi2((double)1, (double)1); + short2 fj1((unsigned long)1); + short2 fj2((unsigned long)1, (unsigned long)1); + short2 fk1((signed long)1); + short2 fk2((signed long)1, (signed long)1); + short2 fl1((unsigned long long)1); + short2 fl2((unsigned long long)1, (unsigned long long)1); + short2 fm1((signed long long)1); + short2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort3() { + short3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + short3 fa1((unsigned char)1); + short3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + short3 fb1((signed char)1); + short3 fb2((signed char)1, (signed char)1, (signed char)1); + short3 fc1((unsigned short)1); + short3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + short3 fd1((signed short)1); + short3 fd2((signed short)1, (signed short)1, (signed short)1); + short3 fe1((unsigned int)1); + short3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + short3 fg1((signed int)1); + short3 fg2((signed int)1, (signed int)1, (signed int)1); + short3 fh1((float)1); + short3 fh2((float)1, (float)1, (float)1); + short3 fi1((double)1); + short3 fi2((double)1, (double)1, (double)1); + short3 fj1((unsigned long)1); + short3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + short3 fk1((signed long)1); + short3 fk2((signed long)1, (signed long)1, (signed long)1); + short3 fl1((unsigned long long)1); + short3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + short3 fm1((signed long long)1); + short3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort4() { + short4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + short4 fa1((unsigned char)1); + short4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + short4 fb1((signed char)1); + short4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + short4 fc1((unsigned short)1); + short4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + short4 fd1((signed short)1); + short4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + short4 fe1((unsigned int)1); + short4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + short4 fg1((signed int)1); + short4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + short4 fh1((float)1); + short4 fh2((float)1, (float)1, (float)1, (float)1); + short4 fi1((double)1); + short4 fi2((double)1, (double)1, (double)1, (double)1); + short4 fj1((unsigned long)1); + short4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + short4 fk1((signed long)1); + short4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + short4 fl1((unsigned long long)1); + short4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + short4 fm1((signed long long)1); + short4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestUInt1() { + uint1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + uint1 fa((unsigned char)1); + uint1 fb((signed char)1); + uint1 fc((unsigned short)1); + uint1 fd((signed short)1); + uint1 fe((unsigned int)1); + uint1 fg((signed int)1); + uint1 fh((float)1); + uint1 fi((double)1); + uint1 fj((unsigned long)1); + uint1 fk((signed long)1); + uint1 fl((unsigned long long)1); + uint1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt2() { + uint2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + uint2 fa1((unsigned char)1); + uint2 fa2((unsigned char)1, (unsigned char)1); + uint2 fb1((signed char)1); + uint2 fb2((signed char)1, (signed char)1); + uint2 fc1((unsigned short)1); + uint2 fc2((unsigned short)1,(unsigned short)1); + uint2 fd1((signed short)1); + uint2 fd2((signed short)1, (signed short)1); + uint2 fe1((unsigned int)1); + uint2 fe2((unsigned int)1, (unsigned int)1); + uint2 fg1((signed int)1); + uint2 fg2((signed int)1, (signed int)1); + uint2 fh1((float)1); + uint2 fh2((float)1, (float)1); + uint2 fi1((double)1); + uint2 fi2((double)1, (double)1); + uint2 fj1((unsigned long)1); + uint2 fj2((unsigned long)1, (unsigned long)1); + uint2 fk1((signed long)1); + uint2 fk2((signed long)1, (signed long)1); + uint2 fl1((unsigned long long)1); + uint2 fl2((unsigned long long)1, (unsigned long long)1); + uint2 fm1((signed long long)1); + uint2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt3() { + uint3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + uint3 fa1((unsigned char)1); + uint3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + uint3 fb1((signed char)1); + uint3 fb2((signed char)1, (signed char)1, (signed char)1); + uint3 fc1((unsigned short)1); + uint3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + uint3 fd1((signed short)1); + uint3 fd2((signed short)1, (signed short)1, (signed short)1); + uint3 fe1((unsigned int)1); + uint3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + uint3 fg1((signed int)1); + uint3 fg2((signed int)1, (signed int)1, (signed int)1); + uint3 fh1((float)1); + uint3 fh2((float)1, (float)1, (float)1); + uint3 fi1((double)1); + uint3 fi2((double)1, (double)1, (double)1); + uint3 fj1((unsigned long)1); + uint3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + uint3 fk1((signed long)1); + uint3 fk2((signed long)1, (signed long)1, (signed long)1); + uint3 fl1((unsigned long long)1); + uint3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uint3 fm1((signed long long)1); + uint3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt4() { + uint4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + uint4 fa1((unsigned char)1); + uint4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + uint4 fb1((signed char)1); + uint4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + uint4 fc1((unsigned short)1); + uint4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + uint4 fd1((signed short)1); + uint4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + uint4 fe1((unsigned int)1); + uint4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + uint4 fg1((signed int)1); + uint4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + uint4 fh1((float)1); + uint4 fh2((float)1, (float)1, (float)1, (float)1); + uint4 fi1((double)1); + uint4 fi2((double)1, (double)1, (double)1, (double)1); + uint4 fj1((unsigned long)1); + uint4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + uint4 fk1((signed long)1); + uint4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + uint4 fl1((unsigned long long)1); + uint4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uint4 fm1((signed long long)1); + uint4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestInt1() { + int1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + int1 fa((unsigned char)1); + int1 fb((signed char)1); + int1 fc((unsigned short)1); + int1 fd((signed short)1); + int1 fe((unsigned int)1); + int1 fg((signed int)1); + int1 fh((float)1); + int1 fi((double)1); + int1 fj((unsigned long)1); + int1 fk((signed long)1); + int1 fl((unsigned long long)1); + int1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt2() { + int2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + int2 fa1((unsigned char)1); + int2 fa2((unsigned char)1, (unsigned char)1); + int2 fb1((signed char)1); + int2 fb2((signed char)1, (signed char)1); + int2 fc1((unsigned short)1); + int2 fc2((unsigned short)1,(unsigned short)1); + int2 fd1((signed short)1); + int2 fd2((signed short)1, (signed short)1); + int2 fe1((unsigned int)1); + int2 fe2((unsigned int)1, (unsigned int)1); + int2 fg1((signed int)1); + int2 fg2((signed int)1, (signed int)1); + int2 fh1((float)1); + int2 fh2((float)1, (float)1); + int2 fi1((double)1); + int2 fi2((double)1, (double)1); + int2 fj1((unsigned long)1); + int2 fj2((unsigned long)1, (unsigned long)1); + int2 fk1((signed long)1); + int2 fk2((signed long)1, (signed long)1); + int2 fl1((unsigned long long)1); + int2 fl2((unsigned long long)1, (unsigned long long)1); + int2 fm1((signed long long)1); + int2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt3() { + int3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + int3 fa1((unsigned char)1); + int3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + int3 fb1((signed char)1); + int3 fb2((signed char)1, (signed char)1, (signed char)1); + int3 fc1((unsigned short)1); + int3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + int3 fd1((signed short)1); + int3 fd2((signed short)1, (signed short)1, (signed short)1); + int3 fe1((unsigned int)1); + int3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + int3 fg1((signed int)1); + int3 fg2((signed int)1, (signed int)1, (signed int)1); + int3 fh1((float)1); + int3 fh2((float)1, (float)1, (float)1); + int3 fi1((double)1); + int3 fi2((double)1, (double)1, (double)1); + int3 fj1((unsigned long)1); + int3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + int3 fk1((signed long)1); + int3 fk2((signed long)1, (signed long)1, (signed long)1); + int3 fl1((unsigned long long)1); + int3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + int3 fm1((signed long long)1); + int3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt4() { + int4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + int4 fa1((unsigned char)1); + int4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + int4 fb1((signed char)1); + int4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + int4 fc1((unsigned short)1); + int4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + int4 fd1((signed short)1); + int4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + int4 fe1((unsigned int)1); + int4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + int4 fg1((signed int)1); + int4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + int4 fh1((float)1); + int4 fh2((float)1, (float)1, (float)1, (float)1); + int4 fi1((double)1); + int4 fi2((double)1, (double)1, (double)1, (double)1); + int4 fj1((unsigned long)1); + int4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + int4 fk1((signed long)1); + int4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + int4 fl1((unsigned long long)1); + int4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + int4 fm1((signed long long)1); + int4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestFloat1() { + float1 f1, f2, f3; + f1.x = 1.0f; + f2.x = 1.0f; + f3 = f1 + f2; + cmpVal1(f3, 2.0f); + f2 = f3 - f1; + cmpVal1(f2, 1.0f); + f1 = f2 * f3; + cmpVal1(f1, 2.0f); + f2 = f1 / f3; + cmpVal1(f2, 2.0f/2.0f); + f1 += f2; + cmpVal1(f1, 3.0f); + f1 -= f2; + cmpVal1(f1, 2.0f); + f1 *= f2; + cmpVal1(f1, 2.0f); + f1 /= f2; + cmpVal1(f1, 2.0f); + f2 = f1++; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); + f2 = f1--; + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); + f2 = ++f1; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); + f2 = --f1; + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); + + f1.x = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal1(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal1(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3.0f); + + float1 fa((unsigned char)1); + float1 fb((signed char)1); + float1 fc((unsigned short)1); + float1 fd((signed short)1); + float1 fe((unsigned int)1); + float1 fg((signed int)1); + float1 fh((float)1); + float1 fi((double)1); + float1 fj((unsigned long)1); + float1 fk((signed long)1); + float1 fl((unsigned long long)1); + float1 fm((signed long long)1); + + + f1.x = 3.0f; + f2.x = 4.0f; + f3.x = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + +bool TestFloat2() { + float2 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f3 = f1 + f2; + cmpVal2(f3, 2.0f); + f2 = f3 - f1; + cmpVal2(f2, 1.0f); + f1 = f2 * f3; + cmpVal2(f1, 2.0f); + f2 = f1 / f3; + cmpVal2(f2, 2.0f/2.0f); + f1 += f2; + cmpVal2(f1, 3.0f); + f1 -= f2; + cmpVal2(f1, 2.0f); + f1 *= f2; + cmpVal2(f1, 2.0f); + f1 /= f2; + cmpVal2(f1, 2.0f); + + f2 = f1++; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); + f2 = f1--; + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); + f2 = ++f1; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); + f2 = --f1; + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal2(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal2(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3.0f); + + float2 fa1((unsigned char)1); + float2 fa2((unsigned char)1, (unsigned char)1); + float2 fb1((signed char)1); + float2 fb2((signed char)1, (signed char)1); + float2 fc1((unsigned short)1); + float2 fc2((unsigned short)1,(unsigned short)1); + float2 fd1((signed short)1); + float2 fd2((signed short)1, (signed short)1); + float2 fe1((unsigned int)1); + float2 fe2((unsigned int)1, (unsigned int)1); + float2 fg1((signed int)1); + float2 fg2((signed int)1, (signed int)1); + float2 fh1((float)1); + float2 fh2((float)1, (float)1); + float2 fi1((double)1); + float2 fi2((double)1, (double)1); + float2 fj1((unsigned long)1); + float2 fj2((unsigned long)1, (unsigned long)1); + float2 fk1((signed long)1); + float2 fk2((signed long)1, (signed long)1); + float2 fl1((unsigned long long)1); + float2 fl2((unsigned long long)1, (unsigned long long)1); + float2 fm1((signed long long)1); + float2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestFloat3() { + float3 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f3 = f1 + f2; + cmpVal3(f3, 2.0f); + f2 = f3 - f1; + cmpVal3(f2, 1.0f); + f1 = f2 * f3; + cmpVal3(f1, 2.0f); + f2 = f1 / f3; + cmpVal3(f2, 2.0f/2.0f); + f1 += f2; + cmpVal3(f1, 3.0f); + f1 -= f2; + cmpVal3(f1, 2.0f); + f1 *= f2; + cmpVal3(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); + f2 = f1--; + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); + f2 = ++f1; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); + f2 = --f1; + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + float3 fa1((unsigned char)1); + float3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + float3 fb1((signed char)1); + float3 fb2((signed char)1, (signed char)1, (signed char)1); + float3 fc1((unsigned short)1); + float3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + float3 fd1((signed short)1); + float3 fd2((signed short)1, (signed short)1, (signed short)1); + float3 fe1((unsigned int)1); + float3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + float3 fg1((signed int)1); + float3 fg2((signed int)1, (signed int)1, (signed int)1); + float3 fh1((float)1); + float3 fh2((float)1, (float)1, (float)1); + float3 fi1((double)1); + float3 fi2((double)1, (double)1, (double)1); + float3 fj1((unsigned long)1); + float3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + float3 fk1((signed long)1); + float3 fk2((signed long)1, (signed long)1, (signed long)1); + float3 fl1((unsigned long long)1); + float3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + float3 fm1((signed long long)1); + float3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestFloat4() { + float4 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f1.w = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f2.w = 1.0f; + f3 = f1 + f2; + cmpVal4(f3, 2.0f); + f2 = f3 - f1; + cmpVal4(f2, 1.0f); + f1 = f2 * f3; + cmpVal4(f1, 2.0f); + f2 = f1 / f3; + cmpVal4(f2, 2.0f/2.0f); + f1 += f2; + cmpVal4(f1, 3.0f); + f1 -= f2; + cmpVal4(f1, 2.0f); + f1 *= f2; + cmpVal4(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); + f2 = f1--; + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); + f2 = ++f1; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); + f2 = --f1; + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal4(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal4(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3.0f); + + float4 fa1((unsigned char)1); + float4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + float4 fb1((signed char)1); + float4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + float4 fc1((unsigned short)1); + float4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + float4 fd1((signed short)1); + float4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + float4 fe1((unsigned int)1); + float4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + float4 fg1((signed int)1); + float4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + float4 fh1((float)1); + float4 fh2((float)1, (float)1, (float)1, (float)1); + float4 fi1((double)1); + float4 fi2((double)1, (double)1, (double)1, (double)1); + float4 fj1((unsigned long)1); + float4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + float4 fk1((signed long)1); + float4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + float4 fl1((unsigned long long)1); + float4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + float4 fm1((signed long long)1); + float4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f2.w = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + f3.w = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + + +bool TestULong1() { + ulong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ulong1 fa((unsigned char)1); + ulong1 fb((signed char)1); + ulong1 fc((unsigned short)1); + ulong1 fd((signed short)1); + ulong1 fe((unsigned int)1); + ulong1 fg((signed int)1); + ulong1 fh((float)1); + ulong1 fi((double)1); + ulong1 fj((unsigned long)1); + ulong1 fk((signed long)1); + ulong1 fl((unsigned long long)1); + ulong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong2() { + ulong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ulong2 fa1((unsigned char)1); + ulong2 fa2((unsigned char)1, (unsigned char)1); + ulong2 fb1((signed char)1); + ulong2 fb2((signed char)1, (signed char)1); + ulong2 fc1((unsigned short)1); + ulong2 fc2((unsigned short)1,(unsigned short)1); + ulong2 fd1((signed short)1); + ulong2 fd2((signed short)1, (signed short)1); + ulong2 fe1((unsigned int)1); + ulong2 fe2((unsigned int)1, (unsigned int)1); + ulong2 fg1((signed int)1); + ulong2 fg2((signed int)1, (signed int)1); + ulong2 fh1((float)1); + ulong2 fh2((float)1, (float)1); + ulong2 fi1((double)1); + ulong2 fi2((double)1, (double)1); + ulong2 fj1((unsigned long)1); + ulong2 fj2((unsigned long)1, (unsigned long)1); + ulong2 fk1((signed long)1); + ulong2 fk2((signed long)1, (signed long)1); + ulong2 fl1((unsigned long long)1); + ulong2 fl2((unsigned long long)1, (unsigned long long)1); + ulong2 fm1((signed long long)1); + ulong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong3() { + ulong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ulong3 fa1((unsigned char)1); + ulong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ulong3 fb1((signed char)1); + ulong3 fb2((signed char)1, (signed char)1, (signed char)1); + ulong3 fc1((unsigned short)1); + ulong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ulong3 fd1((signed short)1); + ulong3 fd2((signed short)1, (signed short)1, (signed short)1); + ulong3 fe1((unsigned int)1); + ulong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ulong3 fg1((signed int)1); + ulong3 fg2((signed int)1, (signed int)1, (signed int)1); + ulong3 fh1((float)1); + ulong3 fh2((float)1, (float)1, (float)1); + ulong3 fi1((double)1); + ulong3 fi2((double)1, (double)1, (double)1); + ulong3 fj1((unsigned long)1); + ulong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ulong3 fk1((signed long)1); + ulong3 fk2((signed long)1, (signed long)1, (signed long)1); + ulong3 fl1((unsigned long long)1); + ulong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulong3 fm1((signed long long)1); + ulong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong4() { + ulong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ulong4 fa1((unsigned char)1); + ulong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ulong4 fb1((signed char)1); + ulong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ulong4 fc1((unsigned short)1); + ulong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ulong4 fd1((signed short)1); + ulong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ulong4 fe1((unsigned int)1); + ulong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ulong4 fg1((signed int)1); + ulong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ulong4 fh1((float)1); + ulong4 fh2((float)1, (float)1, (float)1, (float)1); + ulong4 fi1((double)1); + ulong4 fi2((double)1, (double)1, (double)1, (double)1); + ulong4 fj1((unsigned long)1); + ulong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ulong4 fk1((signed long)1); + ulong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ulong4 fl1((unsigned long long)1); + ulong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulong4 fm1((signed long long)1); + ulong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + long1 fa((unsigned char)1); + long1 fb((signed char)1); + long1 fc((unsigned short)1); + long1 fd((signed short)1); + long1 fe((unsigned int)1); + long1 fg((signed int)1); + long1 fh((float)1); + long1 fi((double)1); + long1 fj((unsigned long)1); + long1 fk((signed long)1); + long1 fl((unsigned long long)1); + long1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + long2 fa1((unsigned char)1); + long2 fa2((unsigned char)1, (unsigned char)1); + long2 fb1((signed char)1); + long2 fb2((signed char)1, (signed char)1); + long2 fc1((unsigned short)1); + long2 fc2((unsigned short)1,(unsigned short)1); + long2 fd1((signed short)1); + long2 fd2((signed short)1, (signed short)1); + long2 fe1((unsigned int)1); + long2 fe2((unsigned int)1, (unsigned int)1); + long2 fg1((signed int)1); + long2 fg2((signed int)1, (signed int)1); + long2 fh1((float)1); + long2 fh2((float)1, (float)1); + long2 fi1((double)1); + long2 fi2((double)1, (double)1); + long2 fj1((unsigned long)1); + long2 fj2((unsigned long)1, (unsigned long)1); + long2 fk1((signed long)1); + long2 fk2((signed long)1, (signed long)1); + long2 fl1((unsigned long long)1); + long2 fl2((unsigned long long)1, (unsigned long long)1); + long2 fm1((signed long long)1); + long2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + + long3 fa1((unsigned char)1); + long3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + long3 fb1((signed char)1); + long3 fb2((signed char)1, (signed char)1, (signed char)1); + long3 fc1((unsigned short)1); + long3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + long3 fd1((signed short)1); + long3 fd2((signed short)1, (signed short)1, (signed short)1); + long3 fe1((unsigned int)1); + long3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + long3 fg1((signed int)1); + long3 fg2((signed int)1, (signed int)1, (signed int)1); + long3 fh1((float)1); + long3 fh2((float)1, (float)1, (float)1); + long3 fi1((double)1); + long3 fi2((double)1, (double)1, (double)1); + long3 fj1((unsigned long)1); + long3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + long3 fk1((signed long)1); + long3 fk2((signed long)1, (signed long)1, (signed long)1); + long3 fl1((unsigned long long)1); + long3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + long3 fm1((signed long long)1); + long3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + long4 fa1((unsigned char)1); + long4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + long4 fb1((signed char)1); + long4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + long4 fc1((unsigned short)1); + long4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + long4 fd1((signed short)1); + long4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + long4 fe1((unsigned int)1); + long4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + long4 fg1((signed int)1); + long4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + long4 fh1((float)1); + long4 fh2((float)1, (float)1, (float)1, (float)1); + long4 fi1((double)1); + long4 fi2((double)1, (double)1, (double)1, (double)1); + long4 fj1((unsigned long)1); + long4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + long4 fk1((signed long)1); + long4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + long4 fl1((unsigned long long)1); + long4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + long4 fm1((signed long long)1); + long4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestDouble1() { + double1 f1, f2, f3; + f1.x = 1.0; + f2.x = 1.0; + f3 = f1 + f2; + cmpVal1(f3, 2.0); + f2 = f3 - f1; + cmpVal1(f2, 1.0); + f1 = f2 * f3; + cmpVal1(f1, 2.0); + f2 = f1 / f3; + cmpVal1(f2, 2.0/2.0); + f1 += f2; + cmpVal1(f1, 3.0); + f1 -= f2; + cmpVal1(f1, 2.0); + f1 *= f2; + cmpVal1(f1, 2.0); + f1 /= f2; + cmpVal1(f1, 2.0); + f2 = f1++; + cmpVal1(f1, 3.0); + cmpVal1(f2, 2.0); + f2 = f1--; + cmpVal1(f2, 3.0); + cmpVal1(f1, 2.0); + f2 = ++f1; + cmpVal1(f1, 3.0); + cmpVal1(f2, 3.0); + f2 = --f1; + cmpVal1(f1, 2.0); + cmpVal1(f1, 2.0); + + f1.x = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (float)1; + cmpVal1(f1, 3.0); + f1 = (float)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (double)1; + cmpVal1(f1, 3.0); + f1 = (double)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3.0); + + double1 fa((unsigned char)1); + double1 fb((signed char)1); + double1 fc((unsigned short)1); + double1 fd((signed short)1); + double1 fe((unsigned int)1); + double1 fg((signed int)1); + double1 fh((float)1); + double1 fi((double)1); + double1 fj((unsigned long)1); + double1 fk((signed long)1); + double1 fl((unsigned long long)1); + double1 fm((signed long long)1); + + + f1.x = 3.0; + f2.x = 4.0; + f3.x = 3.0; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + +bool TestDouble2() { + double2 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f2.x = 1.0; + f2.y = 1.0; + f3 = f1 + f2; + cmpVal2(f3, 2.0); + f2 = f3 - f1; + cmpVal2(f2, 1.0); + f1 = f2 * f3; + cmpVal2(f1, 2.0); + f2 = f1 / f3; + cmpVal2(f2, 2.0f/2.0); + f1 += f2; + cmpVal2(f1, 3.0); + f1 -= f2; + cmpVal2(f1, 2.0); + f1 *= f2; + cmpVal2(f1, 2.0); + f1 /= f2; + cmpVal2(f1, 2.0); + + f2 = f1++; + cmpVal2(f1, 3.0); + cmpVal2(f2, 2.0); + f2 = f1--; + cmpVal2(f2, 3.0); + cmpVal2(f1, 2.0); + f2 = ++f1; + cmpVal2(f1, 3.0); + cmpVal2(f2, 3.0); + f2 = --f1; + cmpVal2(f1, 2.0); + cmpVal2(f1, 2.0); + + f1.x = 3.0; + f1.y = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (float)1; + cmpVal2(f1, 3.0); + f1 = (float)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (double)1; + cmpVal2(f1, 3.0); + f1 = (double)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3.0); + + double2 fa1((unsigned char)1); + double2 fa2((unsigned char)1, (unsigned char)1); + double2 fb1((signed char)1); + double2 fb2((signed char)1, (signed char)1); + double2 fc1((unsigned short)1); + double2 fc2((unsigned short)1,(unsigned short)1); + double2 fd1((signed short)1); + double2 fd2((signed short)1, (signed short)1); + double2 fe1((unsigned int)1); + double2 fe2((unsigned int)1, (unsigned int)1); + double2 fg1((signed int)1); + double2 fg2((signed int)1, (signed int)1); + double2 fh1((float)1); + double2 fh2((float)1, (float)1); + double2 fi1((double)1); + double2 fi2((double)1, (double)1); + double2 fj1((unsigned long)1); + double2 fj2((unsigned long)1, (unsigned long)1); + double2 fk1((signed long)1); + double2 fk2((signed long)1, (signed long)1); + double2 fl1((unsigned long long)1); + double2 fl2((unsigned long long)1, (unsigned long long)1); + double2 fm1((signed long long)1); + double2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f3.x = 3.0; + f3.y = 3.0; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestDouble3() { + double3 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f1.z = 1.0; + f2.x = 1.0; + f2.y = 1.0; + f2.z = 1.0; + f3 = f1 + f2; + cmpVal3(f3, 2.0); + f2 = f3 - f1; + cmpVal3(f2, 1.0); + f1 = f2 * f3; + cmpVal3(f1, 2.0); + f2 = f1 / f3; + cmpVal3(f2, 2.0f/2.0); + f1 += f2; + cmpVal3(f1, 3.0); + f1 -= f2; + cmpVal3(f1, 2.0); + f1 *= f2; + cmpVal3(f1, 2.0); + f1 /= f2; + f2 = f1++; + cmpVal3(f1, 3.0); + cmpVal3(f2, 2.0); + f2 = f1--; + cmpVal3(f2, 3.0); + cmpVal3(f1, 2.0); + f2 = ++f1; + cmpVal3(f1, 3.0); + cmpVal3(f2, 3.0); + f2 = --f1; + cmpVal3(f1, 2.0); + cmpVal3(f1, 2.0); + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (float)1; + cmpVal3(f1, 3.0); + f1 = (float)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (double)1; + cmpVal3(f1, 3.0); + f1 = (double)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3.0); + + double3 fa1((unsigned char)1); + double3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + double3 fb1((signed char)1); + double3 fb2((signed char)1, (signed char)1, (signed char)1); + double3 fc1((unsigned short)1); + double3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + double3 fd1((signed short)1); + double3 fd2((signed short)1, (signed short)1, (signed short)1); + double3 fe1((unsigned int)1); + double3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + double3 fg1((signed int)1); + double3 fg2((signed int)1, (signed int)1, (signed int)1); + double3 fh1((float)1); + double3 fh2((float)1, (float)1, (float)1); + double3 fi1((double)1); + double3 fi2((double)1, (double)1, (double)1); + double3 fj1((unsigned long)1); + double3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + double3 fk1((signed long)1); + double3 fk2((signed long)1, (signed long)1, (signed long)1); + double3 fl1((unsigned long long)1); + double3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + double3 fm1((signed long long)1); + double3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f2.z = 4.0; + f3.x = 3.0; + f3.y = 3.0; + f3.z = 3.0; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestDouble4() { + double4 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f1.z = 1.0; + f1.w = 1.0; + f2.x = 1.0; + f2.y = 1.0; + f2.z = 1.0; + f2.w = 1.0; + f3 = f1 + f2; + cmpVal4(f3, 2.0); + f2 = f3 - f1; + cmpVal4(f2, 1.0); + f1 = f2 * f3; + cmpVal4(f1, 2.0); + f2 = f1 / f3; + cmpVal4(f2, 2.0f/2.0); + f1 += f2; + cmpVal4(f1, 3.0); + f1 -= f2; + cmpVal4(f1, 2.0); + f1 *= f2; + cmpVal4(f1, 2.0); + f1 /= f2; + f2 = f1++; + cmpVal4(f1, 3.0); + cmpVal4(f2, 2.0); + f2 = f1--; + cmpVal4(f2, 3.0); + cmpVal4(f1, 2.0); + f2 = ++f1; + cmpVal4(f1, 3.0); + cmpVal4(f2, 3.0); + f2 = --f1; + cmpVal4(f1, 2.0); + cmpVal4(f1, 2.0); + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1.w = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (float)1; + cmpVal4(f1, 3.0); + f1 = (float)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (double)1; + cmpVal4(f1, 3.0); + f1 = (double)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3.0); + + double4 fa1((unsigned char)1); + double4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + double4 fb1((signed char)1); + double4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + double4 fc1((unsigned short)1); + double4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + double4 fd1((signed short)1); + double4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + double4 fe1((unsigned int)1); + double4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + double4 fg1((signed int)1); + double4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + double4 fh1((float)1); + double4 fh2((float)1, (float)1, (float)1, (float)1); + double4 fi1((double)1); + double4 fi2((double)1, (double)1, (double)1, (double)1); + double4 fj1((unsigned long)1); + double4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + double4 fk1((signed long)1); + double4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + double4 fl1((unsigned long long)1); + double4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + double4 fm1((signed long long)1); + double4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1.w = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f2.z = 4.0; + f2.w = 4.0; + f3.x = 3.0; + f3.y = 3.0; + f3.z = 3.0; + f3.w = 3.0; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + + +bool TestULongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ulonglong1 fa((unsigned char)1); + ulonglong1 fb((signed char)1); + ulonglong1 fc((unsigned short)1); + ulonglong1 fd((signed short)1); + ulonglong1 fe((unsigned int)1); + ulonglong1 fg((signed int)1); + ulonglong1 fh((float)1); + ulonglong1 fi((double)1); + ulonglong1 fj((unsigned long)1); + ulonglong1 fk((signed long)1); + ulonglong1 fl((unsigned long long)1); + ulonglong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ulonglong2 fa1((unsigned char)1); + ulonglong2 fa2((unsigned char)1, (unsigned char)1); + ulonglong2 fb1((signed char)1); + ulonglong2 fb2((signed char)1, (signed char)1); + ulonglong2 fc1((unsigned short)1); + ulonglong2 fc2((unsigned short)1,(unsigned short)1); + ulonglong2 fd1((signed short)1); + ulonglong2 fd2((signed short)1, (signed short)1); + ulonglong2 fe1((unsigned int)1); + ulonglong2 fe2((unsigned int)1, (unsigned int)1); + ulonglong2 fg1((signed int)1); + ulonglong2 fg2((signed int)1, (signed int)1); + ulonglong2 fh1((float)1); + ulonglong2 fh2((float)1, (float)1); + ulonglong2 fi1((double)1); + ulonglong2 fi2((double)1, (double)1); + ulonglong2 fj1((unsigned long)1); + ulonglong2 fj2((unsigned long)1, (unsigned long)1); + ulonglong2 fk1((signed long)1); + ulonglong2 fk2((signed long)1, (signed long)1); + ulonglong2 fl1((unsigned long long)1); + ulonglong2 fl2((unsigned long long)1, (unsigned long long)1); + ulonglong2 fm1((signed long long)1); + ulonglong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ulonglong3 fa1((unsigned char)1); + ulonglong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong3 fb1((signed char)1); + ulonglong3 fb2((signed char)1, (signed char)1, (signed char)1); + ulonglong3 fc1((unsigned short)1); + ulonglong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong3 fd1((signed short)1); + ulonglong3 fd2((signed short)1, (signed short)1, (signed short)1); + ulonglong3 fe1((unsigned int)1); + ulonglong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong3 fg1((signed int)1); + ulonglong3 fg2((signed int)1, (signed int)1, (signed int)1); + ulonglong3 fh1((float)1); + ulonglong3 fh2((float)1, (float)1, (float)1); + ulonglong3 fi1((double)1); + ulonglong3 fi2((double)1, (double)1, (double)1); + ulonglong3 fj1((unsigned long)1); + ulonglong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong3 fk1((signed long)1); + ulonglong3 fk2((signed long)1, (signed long)1, (signed long)1); + ulonglong3 fl1((unsigned long long)1); + ulonglong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong3 fm1((signed long long)1); + ulonglong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ulonglong4 fa1((unsigned char)1); + ulonglong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong4 fb1((signed char)1); + ulonglong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ulonglong4 fc1((unsigned short)1); + ulonglong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong4 fd1((signed short)1); + ulonglong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ulonglong4 fe1((unsigned int)1); + ulonglong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong4 fg1((signed int)1); + ulonglong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ulonglong4 fh1((float)1); + ulonglong4 fh2((float)1, (float)1, (float)1, (float)1); + ulonglong4 fi1((double)1); + ulonglong4 fi2((double)1, (double)1, (double)1, (double)1); + ulonglong4 fj1((unsigned long)1); + ulonglong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong4 fk1((signed long)1); + ulonglong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ulonglong4 fl1((unsigned long long)1); + ulonglong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong4 fm1((signed long long)1); + ulonglong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestLongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + longlong1 fa((unsigned char)1); + longlong1 fb((signed char)1); + longlong1 fc((unsigned short)1); + longlong1 fd((signed short)1); + longlong1 fe((unsigned int)1); + longlong1 fg((signed int)1); + longlong1 fh((float)1); + longlong1 fi((double)1); + longlong1 fj((unsigned long)1); + longlong1 fk((signed long)1); + longlong1 fl((unsigned long long)1); + longlong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + longlong2 fa1((unsigned char)1); + longlong2 fa2((unsigned char)1, (unsigned char)1); + longlong2 fb1((signed char)1); + longlong2 fb2((signed char)1, (signed char)1); + longlong2 fc1((unsigned short)1); + longlong2 fc2((unsigned short)1,(unsigned short)1); + longlong2 fd1((signed short)1); + longlong2 fd2((signed short)1, (signed short)1); + longlong2 fe1((unsigned int)1); + longlong2 fe2((unsigned int)1, (unsigned int)1); + longlong2 fg1((signed int)1); + longlong2 fg2((signed int)1, (signed int)1); + longlong2 fh1((float)1); + longlong2 fh2((float)1, (float)1); + longlong2 fi1((double)1); + longlong2 fi2((double)1, (double)1); + longlong2 fj1((unsigned long)1); + longlong2 fj2((unsigned long)1, (unsigned long)1); + longlong2 fk1((signed long)1); + longlong2 fk2((signed long)1, (signed long)1); + longlong2 fl1((unsigned long long)1); + longlong2 fl2((unsigned long long)1, (unsigned long long)1); + longlong2 fm1((signed long long)1); + longlong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + longlong3 fa1((unsigned char)1); + longlong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong3 fb1((signed char)1); + longlong3 fb2((signed char)1, (signed char)1, (signed char)1); + longlong3 fc1((unsigned short)1); + longlong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong3 fd1((signed short)1); + longlong3 fd2((signed short)1, (signed short)1, (signed short)1); + longlong3 fe1((unsigned int)1); + longlong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong3 fg1((signed int)1); + longlong3 fg2((signed int)1, (signed int)1, (signed int)1); + longlong3 fh1((float)1); + longlong3 fh2((float)1, (float)1, (float)1); + longlong3 fi1((double)1); + longlong3 fi2((double)1, (double)1, (double)1); + longlong3 fj1((unsigned long)1); + longlong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong3 fk1((signed long)1); + longlong3 fk2((signed long)1, (signed long)1, (signed long)1); + longlong3 fl1((unsigned long long)1); + longlong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong3 fm1((signed long long)1); + longlong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + longlong4 fa1((unsigned char)1); + longlong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong4 fb1((signed char)1); + longlong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + longlong4 fc1((unsigned short)1); + longlong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong4 fd1((signed short)1); + longlong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + longlong4 fe1((unsigned int)1); + longlong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong4 fg1((signed int)1); + longlong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + longlong4 fh1((float)1); + longlong4 fh2((float)1, (float)1, (float)1, (float)1); + longlong4 fi1((double)1); + longlong4 fi2((double)1, (double)1, (double)1, (double)1); + longlong4 fj1((unsigned long)1); + longlong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong4 fk1((signed long)1); + longlong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + longlong4 fl1((unsigned long long)1); + longlong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong4 fm1((signed long long)1); + longlong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +int main() { + assert(sizeof(float1) == 4); + assert(sizeof(float2) == 8); + assert(sizeof(float3) == 12); + assert(sizeof(float4) == 16); + assert(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestDouble1() && TestDouble2() && TestDouble3() && TestDouble4() + && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() + && TestChar1() && TestChar2() && TestChar3() && TestChar4() + && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() + && TestShort1() && TestShort2() && TestShort3() && TestShort4() + && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() + && TestInt1() && TestInt2() && TestInt3() && TestInt4() + && TestULong1() && TestULong2() && TestULong3() && TestULong4() + && TestLong1() && TestLong2() && TestLong3() && TestLong4() + && TestULongLong1() && TestULongLong2() && TestULongLong3() && TestULongLong4() + && TestLongLong1() && TestLongLong2() && TestLongLong3() && TestLongLong4() == true); + passed(); + float1 f1 = make_float1(1.0f); +} diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp new file mode 100644 index 0000000000..265cd00b22 --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp @@ -0,0 +1,3895 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc + * RUN: %t + * HIT_END + */ + +#include +#include +#include"test_common.h" +#define cmpVal1(in, exp) \ + if(in.x != exp) { \ + } \ + +#define cmpVal2(in, exp) \ + if(in.x != exp || in.y != exp) { \ + } \ + +#define cmpVal3(in, exp) \ + if(in.x != exp || in.y != exp || in.z != exp) { \ + } \ + +#define cmpVal4(in, exp) \ + if(in.x != exp || in.y != exp || in.z != exp || in.w != exp ) { \ + } \ + +__device__ bool TestUChar1() { + uchar1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 253); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + +// signed char sc = 1; + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar2() { + uchar2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar3() { + uchar3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar4() { + uchar4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar1() { + char1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar2() { + char2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar3() { + char3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar4() { + char4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort1() { + ushort1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort2() { + ushort2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort3() { + ushort3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort4() { + ushort4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort1() { + short1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort2() { + short2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort3() { + short3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort4() { + short4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestUInt1() { + uint1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt2() { + uint2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt3() { + uint3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt4() { + uint4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt1() { + int1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt2() { + int2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt3() { + int3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt4() { + int4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong1() { + ulong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong2() { + ulong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong3() { + ulong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong4() { + ulong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestFloat1() { + float1 f1, f2, f3; +// float1 f4(1); +// cmpVal1(f4, 1.0f); +// float1 f5(2.0f); +// cmpVal1(f5, 2.0f); + f1.x = 1.0f; + f2.x = 1.0f; + f3 = f1 + f2; + cmpVal1(f3, 2.0f); + f2 = f3 - f1; + cmpVal1(f2, 1.0f); + f1 = f2 * f3; + cmpVal1(f1, 2.0f); + f2 = f1 / f3; + cmpVal1(f2, 2.0f/2.0f); + f1 += f2; + cmpVal1(f1, 3.0f); + f1 -= f2; + cmpVal1(f1, 2.0f); + f1 *= f2; + cmpVal1(f1, 2.0f); + f1 /= f2; + cmpVal1(f1, 2.0f); + f2 = f1++; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); + f2 = f1--; + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); + f2 = ++f1; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); + f2 = --f1; + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); + + f1.x = 3.0f; + f2.x = 4.0f; + f3.x = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + return true; +} + +__device__ bool TestFloat2() { + float2 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f3 = f1 + f2; + cmpVal2(f3, 2.0f); + f2 = f3 - f1; + cmpVal2(f2, 1.0f); + f1 = f2 * f3; + cmpVal2(f1, 2.0f); + f2 = f1 / f3; + cmpVal2(f2, 2.0f/2.0f); + f1 += f2; + cmpVal2(f1, 3.0f); + f1 -= f2; + cmpVal2(f1, 2.0f); + f1 *= f2; + cmpVal2(f1, 2.0f); + f1 /= f2; + cmpVal2(f1, 2.0f); + + f2 = f1++; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); + f2 = f1--; + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); + f2 = ++f1; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); + f2 = --f1; + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + + return true; +} + +__device__ bool TestFloat3() { + float3 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f3 = f1 + f2; + cmpVal3(f3, 2.0f); + f2 = f3 - f1; + cmpVal3(f2, 1.0f); + f1 = f2 * f3; + cmpVal3(f1, 2.0f); + f2 = f1 / f3; + cmpVal3(f2, 2.0f/2.0f); + f1 += f2; + cmpVal3(f1, 3.0f); + f1 -= f2; + cmpVal3(f1, 2.0f); + f1 *= f2; + cmpVal3(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); + f2 = f1--; + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); + f2 = ++f1; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); + f2 = --f1; + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + + return true; +} + + +__device__ bool TestFloat4() { + float4 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f1.w = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f2.w = 1.0f; + f3 = f1 + f2; + cmpVal4(f3, 2.0f); + f2 = f3 - f1; + cmpVal4(f2, 1.0f); + f1 = f2 * f3; + cmpVal4(f1, 2.0f); + f2 = f1 / f3; + cmpVal4(f2, 2.0f/2.0f); + f1 += f2; + cmpVal4(f1, 3.0f); + f1 -= f2; + cmpVal4(f1, 2.0f); + f1 *= f2; + cmpVal4(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); + f2 = f1--; + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); + f2 = ++f1; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); + f2 = --f1; + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f2.w = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + f3.w = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + return true; +} + +__device__ bool TestULongLong1() { + ulonglong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestULongLong2() { + ulonglong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULongLong3() { + ulonglong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULongLong4() { + ulonglong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__global__ void CheckVectorTypes(hipLaunchParm lp, bool *ptr){ + if(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() + && TestChar1() && TestChar2() && TestChar3() && TestChar4() + && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() + && TestShort1() && TestShort2() && TestShort3() && TestShort4() + && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() + && TestInt1() && TestInt2() && TestInt3() && TestInt4() + && TestULong1() && TestULong2() && TestULong3() && TestULong4() + && TestLong1() && TestLong2() && TestLong3() && TestLong4() + && TestULongLong1() && TestULongLong2() && TestULongLong3() && TestULongLong4() == true){ + ptr[0] = true; + } +} + +int main() { + assert(sizeof(float1) == 4); + assert(sizeof(float2) == 8); + assert(sizeof(float3) == 12); + assert(sizeof(float4) == 16); + + bool* ptr = nullptr; + if (hipMalloc(&ptr, sizeof(bool)) != HIP_SUCCESS) return EXIT_FAILURE; + std::unique_ptr correct{ptr, hipFree}; + hipLaunchKernel( + CheckVectorTypes, dim3(1,1,1), dim3(1,1,1), 0, 0, correct.get()); + bool passed = false; + if (hipMemcpyDtoH(&passed, correct.get(), sizeof(bool)) != HIP_SUCCESS) { + return EXIT_FAILURE; + } + + if (passed == true){ + std::cout << "PASSED" << std::endl; + return 0; + } + else + return EXIT_FAILURE; +} + diff --git a/projects/hip/tests/src/deviceLib/hip_anyall.cpp b/projects/hip/tests/src/deviceLib/hip_anyall.cpp index a562b7810e..bba7915052 100644 --- a/projects/hip/tests/src/deviceLib/hip_anyall.cpp +++ b/projects/hip/tests/src/deviceLib/hip_anyall.cpp @@ -29,7 +29,8 @@ THE SOFTWARE. #include #include -#include "hip/hip_runtime.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) __global__ void diff --git a/projects/hip/tests/src/deviceLib/hip_ballot.cpp b/projects/hip/tests/src/deviceLib/hip_ballot.cpp index 236ceb57fe..742c47a065 100644 --- a/projects/hip/tests/src/deviceLib/hip_ballot.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ballot.cpp @@ -25,10 +25,12 @@ THE SOFTWARE. #include -#include "hip/hip_runtime.h" +#include +#include + #define HIP_ASSERT(x) (assert((x)==hipSuccess)) -__global__ void +__global__ void gpu_ballot(hipLaunchParm lp, unsigned int* device_ballot, int Num_Warps_per_Block,int pshift) { @@ -39,7 +41,7 @@ __global__ void #else atomicAdd(&device_ballot[warp_num+hipBlockIdx_x*Num_Warps_per_Block],__popc(__ballot(tid - 245))); #endif - + } @@ -47,24 +49,24 @@ int main(int argc, char *argv[]) { int warpSize, pshift; hipDeviceProp_t devProp; hipGetDeviceProperties(&devProp, 0); - + warpSize = devProp.warpSize; int w = warpSize; - pshift = 0; + pshift = 0; while (w >>= 1) ++pshift; - + unsigned int Num_Threads_per_Block = 512; unsigned int Num_Blocks_per_Grid = 1; unsigned int Num_Warps_per_Block = Num_Threads_per_Block/warpSize; unsigned int Num_Warps_per_Grid = (Num_Threads_per_Block*Num_Blocks_per_Grid)/warpSize; unsigned int* host_ballot = (unsigned int*)malloc(Num_Warps_per_Grid*sizeof(unsigned int)); - unsigned int* device_ballot; + unsigned int* device_ballot; HIP_ASSERT(hipMalloc((void**)&device_ballot, Num_Warps_per_Grid*sizeof(unsigned int))); int divergent_count =0; for (int i=0; i #include #include "hip/hip_runtime.h" - +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -181,4 +181,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_clz.cpp b/projects/hip/tests/src/deviceLib/hip_clz.cpp index 5c60b29a2d..bdb31f3e8d 100644 --- a/projects/hip/tests/src/deviceLib/hip_clz.cpp +++ b/projects/hip/tests/src/deviceLib/hip_clz.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) #define WIDTH 8 @@ -188,4 +189,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_ffs.cpp b/projects/hip/tests/src/deviceLib/hip_ffs.cpp index dfdc439a21..c855ede060 100644 --- a/projects/hip/tests/src/deviceLib/hip_ffs.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ffs.cpp @@ -31,8 +31,8 @@ THE SOFTWARE. #include #include #include -#include "hip/hip_runtime.h" - +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -184,4 +184,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_popc.cpp b/projects/hip/tests/src/deviceLib/hip_popc.cpp index b40bbd2000..e503e55b42 100644 --- a/projects/hip/tests/src/deviceLib/hip_popc.cpp +++ b/projects/hip/tests/src/deviceLib/hip_popc.cpp @@ -31,8 +31,8 @@ THE SOFTWARE. #include #include #include -#include "hip/hip_runtime.h" - +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -172,4 +172,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp b/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp index 0737533175..171ff1afd0 100644 --- a/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp +++ b/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" +#include "hip/hip_vector_types.h" #include "test_common.h" #if (__hcc_workweek__ >= 16164) || defined (__HIP_PLATFORM_NVCC__) @@ -389,4 +390,3 @@ int main() { } #endif - diff --git a/projects/hip/tests/src/deviceLib/hip_trig.cpp b/projects/hip/tests/src/deviceLib/hip_trig.cpp index 7f9b5d60b0..5ec28101f3 100644 --- a/projects/hip/tests/src/deviceLib/hip_trig.cpp +++ b/projects/hip/tests/src/deviceLib/hip_trig.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s * RUN: %t * HIT_END */ @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include #include"test_common.h" +#include #define LEN 512 #define SIZE LEN<<2 diff --git a/projects/hip/tests/src/g++/hipMalloc.cpp b/projects/hip/tests/src/g++/hipMalloc.cpp new file mode 100644 index 0000000000..24e3126c96 --- /dev/null +++ b/projects/hip/tests/src/g++/hipMalloc.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + int *Ad; + hipMalloc((void**)&Ad, 1024); +} diff --git a/projects/hip/tests/src/gcc/hipMalloc.c b/projects/hip/tests/src/gcc/hipMalloc.c new file mode 100644 index 0000000000..95e4bf29ea --- /dev/null +++ b/projects/hip/tests/src/gcc/hipMalloc.c @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + int *Ad; + hipMalloc((void**)&Ad, 1024); +} diff --git a/projects/hip/tests/src/hipC.c b/projects/hip/tests/src/hipC.c index 50177ac6c2..644df6c98f 100644 --- a/projects/hip/tests/src/hipC.c +++ b/projects/hip/tests/src/hipC.c @@ -1,4 +1,33 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s EXCLUDE_HIP_PLATFORM all + * RUN: %t + * HIT_END + */ + #include "hip/hip_runtime.h" +#include "test_common.h" #include #define ITER 1<<20 @@ -22,4 +51,5 @@ int main(){ dimBlock.x = 1, dimBlock.y = 1, dimGrid.z = 1; hipLaunchKernel(HIP_KERNEL_NAME(Iter), dimGrid, dimBlock, 0, 0, Ad); hipMemcpy(&A, Ad, SIZE, hipMemcpyDeviceToHost); + passed(); } diff --git a/projects/hip/tests/src/hipC.cpp b/projects/hip/tests/src/hipC.cpp index 3380e8abd9..8abb877808 100644 --- a/projects/hip/tests/src/hipC.cpp +++ b/projects/hip/tests/src/hipC.cpp @@ -1,5 +1,29 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + + #include "hip/hip_runtime.h" -#include +#include "test_common.h" +#include #define ITER 1<<20 #define SIZE 1024*1024*sizeof(int) @@ -19,4 +43,5 @@ int main(){ hipMemcpy(Ad, &A, SIZE, hipMemcpyHostToDevice); hipLaunchKernel(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0, 0, Ad); hipMemcpy(&A, Ad, SIZE, hipMemcpyDeviceToHost); + passed(); } diff --git a/projects/hip/tests/src/hipCKernel.c b/projects/hip/tests/src/hipCKernel.c index 19a034d843..7a72cf84ca 100644 --- a/projects/hip/tests/src/hipCKernel.c +++ b/projects/hip/tests/src/hipCKernel.c @@ -3,6 +3,7 @@ __global__ void Kernel(hipLaunchParm lp, float *Ad){ int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; + Ad[tx] += Ad[tx-1]; } int main(){ diff --git a/projects/hip/tests/src/hipChooseDevice.cpp b/projects/hip/tests/src/hipChooseDevice.cpp deleted file mode 100644 index 4f289b9eb8..0000000000 --- a/projects/hip/tests/src/hipChooseDevice.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include "hip/hip_runtime.h" -int main( void ) { - hipDeviceProp_t prop; - int dev; - - hipGetDevice( &dev ) ; - printf( "ID of current HIP device: %d\n", dev ); - - memset( &prop, 0, sizeof( hipDeviceProp_t ) ); - prop.major = 1; - prop.minor = 3; - hipChooseDevice( &dev, &prop ); - printf( "ID of hip device closest to revision 1.3: %d\n", dev ); - - hipSetDevice( dev ); -} diff --git a/projects/hip/tests/src/hipHcc.cpp b/projects/hip/tests/src/hipHcc.cpp index b09898309e..92d9e3e88d 100644 --- a/projects/hip/tests/src/hipHcc.cpp +++ b/projects/hip/tests/src/hipHcc.cpp @@ -22,15 +22,15 @@ THE SOFTWARE. // Test the HCC-specific API extensions for HIP: /* HIT_START - * BUILD: %t %s HCC_OPTIONS -stdlib=libc++ - * RUN: %t + * BUILD: %t %s + * RUN: %t EXCLUDE_HIP_PLATFORM all * HIT_END */ #include #include #include "hip/hip_runtime.h" -#include "hip/hcc.h" +#include "hip/hip_hcc.h" #include "test_common.h" #define CHECK(error) \ @@ -61,4 +61,3 @@ int main(int argc, char *argv[]) passed(); }; - diff --git a/projects/hip/tests/src/hipPeerToPeer_simple.cpp b/projects/hip/tests/src/hipPeerToPeer_simple.cpp index 1dfbdafdfc..1ea594f4bb 100644 --- a/projects/hip/tests/src/hipPeerToPeer_simple.cpp +++ b/projects/hip/tests/src/hipPeerToPeer_simple.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -50,7 +50,7 @@ void help(char *argv[]) }; -static hipError_t myHipMemcpy(void *dest, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream, bool async) +static hipError_t myHipMemcpy(void *dest, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream, bool async) { if (async) { hipError_t e = hipMemcpyAsync(dest, src, sizeBytes, kind, stream); @@ -78,7 +78,7 @@ void parseMyArguments(int argc, char *argv[]) p_mirrorPeers = true; } else if (!strcmp(arg, "--peerDevice")) { if (++i >= argc || !HipTest::parseInt(argv[i], &p_peerDevice)) { - failed("Bad peerDevice argument"); + failed("Bad peerDevice argument"); } } else { failed("Bad argument '%s'", arg); @@ -101,7 +101,7 @@ void syncBothDevices() // Sets globals g_currentDevice, g_peerDevice -void setupPeerTests() +void setupPeerTests() { int deviceCnt; @@ -159,17 +159,17 @@ void enablePeerFirst(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipMalloc(&A_d0, Nbytes) ); - HIPCHECK (hipMemset(A_d0, memsetval, Nbytes) ); + HIPCHECK (hipMemset(A_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); // Device0 push to device1, using P2P: - // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a + // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a // a host staging copy for the P2P access. HIPCHECK (hipSetDevice(p_memcpyWithPeer ? g_peerDevice : g_currentDevice)); HIPCHECK (myHipMemcpy(A_d1, A_d0, Nbytes, hipMemcpyDefault, 0/*stream*/, useAsyncCopy)); // This is P2P copy. @@ -177,7 +177,7 @@ void enablePeerFirst(bool useAsyncCopy) // Copy data back to host: // Have to wait for previous operation to finish, since we are switching to another one: HIPCHECK(hipDeviceSynchronize()); - + HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (myHipMemcpy(A_h, A_d1, Nbytes, hipMemcpyDeviceToHost, 0/*stream*/, useAsyncCopy)); HIPCHECK(hipDeviceSynchronize()); @@ -215,12 +215,12 @@ void allocMemoryFirst(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipMalloc(&A_d0, Nbytes) ); - HIPCHECK ( hipMemset(A_d0, memsetval, Nbytes) ); + HIPCHECK ( hipMemset(A_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK ( hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK ( hipMemset(A_d1, 0x13, Nbytes) ); //--- @@ -268,7 +268,7 @@ void allocMemoryFirst(bool useAsyncCopy) // Test which tests peer H2D copy - ie: copy-engine=1, dst=1, src=0 (Host) // A_d0 is pinned host on dev0 (this) // A_d1 is device memory on dev1 (peer) -// +// void testPeerHostToDevice(bool useAsyncCopy) { printf ("\n==testing: %s useAsyncCopy=%d\n", __func__, useAsyncCopy); @@ -299,12 +299,12 @@ void testPeerHostToDevice(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipHostMalloc(&A_host_d0, Nbytes) ); - HIPCHECK (hipMemset(A_host_d0, memsetval, Nbytes) ); + HIPCHECK (hipMemset(A_host_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); bool firstAsyncCopy = useAsyncCopy; /*TODO - should be useAsyncCopy*/ @@ -313,17 +313,17 @@ void testPeerHostToDevice(bool useAsyncCopy) // Device0 push to device1, using P2P: - // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a + // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a // a host staging copy for the P2P access. if (p_memcpyWithPeer) { // p_memcpyWithPeer=1 case is HostToDevice. - // if p_mirrorPeers = 1, this is accelerated copy over PCIe. + // if p_mirrorPeers = 1, this is accelerated copy over PCIe. // if p_mirrorPeers = 0, this should fall back to host (because peer can't see A_host_d0) HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (myHipMemcpy(A_d1, A_host_d0, Nbytes, hipMemcpyHostToDevice, 0/*stream*/, firstAsyncCopy)); // This is P2P copy. } else { // p_memcpyWithPeer=0 case is HostToDevice. - // if p_mirrorPeers = 1, this is accelerated copy over PCIe. + // if p_mirrorPeers = 1, this is accelerated copy over PCIe. // if p_mirrorPeers = 0, this should fall back to host (because device0 can't see A_d1) HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (myHipMemcpy(A_d1, A_host_d0, Nbytes, hipMemcpyHostToDevice, 0/*stream*/, firstAsyncCopy)); // This is P2P copy. @@ -367,7 +367,7 @@ void simpleNegative() HIPASSERT( e == hipSuccess); // no error returned, it doesn't hurt to ask. HIPASSERT (canAccessPeer == 0); // but self is not a peer. - e = hipSuccess; + e = hipSuccess; //--- // Enable same device twice in a row: HIPCHECK(hipSetDevice(g_currentDevice)); @@ -381,7 +381,7 @@ void simpleNegative() e =(hipDeviceDisablePeerAccess(g_peerDevice)); HIPASSERT (e == hipErrorPeerAccessNotEnabled); - + // More tests here: printf ("==done: %s\n\n", __func__); } diff --git a/projects/hip/tests/src/hipTestHalf.cpp b/projects/hip/tests/src/hipTestHalf.cpp deleted file mode 100644 index 7455037923..0000000000 --- a/projects/hip/tests/src/hipTestHalf.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -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. -*/ - -#include -#include -#include "hip/hip_runtime_api.h" - -#define DSIZE 4 -#define SCF 0.5f -#define nTPB 256 -__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){ - - int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x; - if (idx < dsize){ - __half scf = __float2half(SCF); - __half kin = __float2half(din[idx]); - __half kout; - - kout = __hmul(kin, scf); - -// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf)); - - dout[idx] = __half2float(kout); - } -} - -int main(){ - - float *hin, *hout, *din, *dout; - hin = (float *)malloc(DSIZE*sizeof(float)); - hout = (float *)malloc(DSIZE*sizeof(float)); - for (int i = 0; i < DSIZE; i++) hin[i] = i; - hipMalloc(&din, DSIZE*sizeof(float)); - hipMalloc(&dout, DSIZE*sizeof(float)); - hipMemcpy(din, hin, DSIZE*sizeof(float), hipMemcpyHostToDevice); - hipLaunchKernel(half_scale_kernel, dim3((DSIZE+nTPB-1)/nTPB),dim3(nTPB), 0, 0, din, dout, DSIZE); - hipMemcpy(hout, dout, DSIZE*sizeof(float), hipMemcpyDeviceToHost); - for (int i = 0; i < DSIZE; i++) printf("%f\n", hout[i]); - return 0; -} diff --git a/projects/hip/tests/src/hipDynamicShared.cpp b/projects/hip/tests/src/kernel/hipDynamicShared.cpp similarity index 97% rename from projects/hip/tests/src/hipDynamicShared.cpp rename to projects/hip/tests/src/kernel/hipDynamicShared.cpp index d5aed7b24f..ba19fcaa0d 100644 --- a/projects/hip/tests/src/hipDynamicShared.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ @@ -45,7 +45,7 @@ __global__ void testExternSharedKernel(hipLaunchParm lp, const T* A_d, const T* // initialize dynamic shared memory if (tid < groupElements) { - sdata[tid] = static_cast(tid); + sdata[tid] = static_cast(tid); } // prefix sum inside dynamic shared memory @@ -146,4 +146,3 @@ int main(int argc, char *argv[]) { passed(); } - diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp new file mode 100644 index 0000000000..95e70a9956 --- /dev/null +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -0,0 +1,62 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc + * RUN: %t EXCLUDE_HIP_PLATFORM nvcc + * HIT_END + */ + + #include "hip/hip_runtime.h" + #include "test_common.h" + +#define LEN 16*1024 +#define SIZE LEN*4 + +__global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) { + HIP_DYNAMIC_SHARED(float, sBd); + int tx = hipThreadIdx_x; + for(int i=0;i 1.0f && B[i] < 3.0f); + } + passed(); +} diff --git a/projects/hip/tests/src/hipKernel.cpp b/projects/hip/tests/src/kernel/hipEmptyKernel.cpp similarity index 89% rename from projects/hip/tests/src/hipKernel.cpp rename to projects/hip/tests/src/kernel/hipEmptyKernel.cpp index bb6135ef5d..37245053be 100644 --- a/projects/hip/tests/src/hipKernel.cpp +++ b/projects/hip/tests/src/kernel/hipEmptyKernel.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -17,6 +17,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include"test_common.h" __global__ void Empty(hipLaunchParm lp, int param){} @@ -24,4 +30,5 @@ __global__ void Empty(hipLaunchParm lp, int param){} int main(){ hipLaunchKernel(HIP_KERNEL_NAME(Empty), dim3(1), dim3(1), 0, 0, 0); hipDeviceSynchronize(); +passed(); } diff --git a/projects/hip/tests/src/kernel/hipGridLaunch.cpp b/projects/hip/tests/src/kernel/hipGridLaunch.cpp index 99c6a29557..6cd724a070 100644 --- a/projects/hip/tests/src/kernel/hipGridLaunch.cpp +++ b/projects/hip/tests/src/kernel/hipGridLaunch.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -33,7 +33,7 @@ THE SOFTWARE. // __device__ maps to __attribute__((hc)) -__device__ int foo(int i) +__device__ int foo(int i) { return i+1; } @@ -96,4 +96,3 @@ int main(int argc, char *argv[]) passed(); } - diff --git a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp index cc170f9c8a..ebb93a8e0d 100644 --- a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp +++ b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ THE SOFTWARE. // Collection of code to make sure that various features in the hip kernel language compile. /* HIT_START - * BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++ + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ @@ -42,7 +42,7 @@ __device__ int deviceVar; // TODO-HCC __constant__ not working yet. __constant__ int constantVar1; -__constant__ __device__ int constantVar2; +__constant__ __device__ int constantVar2; // Test HOST space: __host__ void foo() { @@ -53,7 +53,7 @@ __device__ __noinline__ int sum1_noinline(int a) { return a+1;}; __device__ __forceinline__ int sum1_forceinline(int a) { return a+1;}; -__device__ __host__ float PlusOne(float x) +__device__ __host__ float PlusOne(float x) { return x + 1.0; } diff --git a/projects/hip/tests/src/hipLaunchParm.cpp b/projects/hip/tests/src/kernel/hipLaunchParm.cpp similarity index 96% rename from projects/hip/tests/src/hipLaunchParm.cpp rename to projects/hip/tests/src/kernel/hipLaunchParm.cpp index 5ffb557662..4dfd8a42ed 100644 --- a/projects/hip/tests/src/hipLaunchParm.cpp +++ b/projects/hip/tests/src/kernel/hipLaunchParm.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index f86e8ace4f..9aeaf59c00 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -17,9 +17,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include +#include "test_common.h" #define HIP_ASSERT(status) \ assert(status == hipSuccess) @@ -56,4 +63,5 @@ int main() { assert(A[i] == B[i]); } + passed(); } diff --git a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp index 826f6164c3..9dd8b053a5 100644 --- a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -17,6 +17,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all + * RUN: %t + * HIT_END + */ + #include #include #include diff --git a/projects/hip/tests/src/kernel/hipTestMemKernel.cpp b/projects/hip/tests/src/kernel/hipTestMemKernel.cpp index bf97fc1dc8..9298e20e1b 100644 --- a/projects/hip/tests/src/kernel/hipTestMemKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMemKernel.cpp @@ -1,6 +1,32 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include +#include"test_common.h" #define LEN8 8 * 4 #define LEN9 9 * 4 @@ -184,4 +210,6 @@ int main(){ delete A; delete B; delete C; + + passed(); } diff --git a/projects/hip/tests/src/kernel/launch_bounds.cpp b/projects/hip/tests/src/kernel/launch_bounds.cpp index 2e10a9204a..3b1476fb11 100644 --- a/projects/hip/tests/src/kernel/launch_bounds.cpp +++ b/projects/hip/tests/src/kernel/launch_bounds.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* HIT_START - * BUILD: %t %s ../test_common.cpp - * RUN: %t - * HIT_END - */ - // Test launch bounds and initialization conditions. #include "hip/hip_runtime.h" @@ -34,7 +28,7 @@ THE SOFTWARE. int p_blockSize = 256; -__global__ +__global__ void __launch_bounds__(256, 2) myKern(hipLaunchParm lp, int *C, const int *A, int N, int xfactor) diff --git a/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp b/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp new file mode 100644 index 0000000000..4ddffe8aad --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include "hip/hip_runtime.h" +#include "test_common.h" + +int main( void ) { + hipDeviceProp_t prop; + int dev; + + hipGetDevice( &dev ) ; + printf( "ID of current HIP device: %d\n", dev ); + + memset( &prop, 0, sizeof( hipDeviceProp_t ) ); + prop.major = 1; + prop.minor = 3; + hipChooseDevice( &dev, &prop ); + printf( "ID of hip device closest to revision 1.3: %d\n", dev ); + + hipSetDevice( dev ); + + passed(); +} diff --git a/projects/hip/tests/src/hipGetDeviceAttribute.cpp b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp similarity index 99% rename from projects/hip/tests/src/hipGetDeviceAttribute.cpp rename to projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp index a67296476f..8e55e2f699 100644 --- a/projects/hip/tests/src/hipGetDeviceAttribute.cpp +++ b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. // Test the device info API extensions for HIP: /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ @@ -89,4 +89,3 @@ int main(int argc, char *argv[]) passed(); }; - diff --git a/projects/hip/tests/src/hipEventRecord.cpp b/projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp similarity index 96% rename from projects/hip/tests/src/hipEventRecord.cpp rename to projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp index f8ef36b0bb..5606b4ab9b 100644 --- a/projects/hip/tests/src/hipEventRecord.cpp +++ b/projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp @@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Test hipEventRecord serialization behavior. -// Through manual inspection of the reported timestamps, can determine if recording a NULL event forces synchronization : -// set +// Through manual inspection of the reported timestamps, can determine if recording a NULL event forces synchronization : +// set /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t --iterations 10 * HIT_END */ @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) unsigned blocks = (N+threadsPerBlock-1)/threadsPerBlock; if (blocks > 1024) blocks = 1024; - if (blocks ==0 ) + if (blocks ==0 ) blocks = 1; printf ("N=%zu (A+B+C= %6.1f MB total) blocks=%u threadsPerBlock=%u iterations=%d\n", N, ((double)3*N*sizeof(float))/1024/1024, blocks, threadsPerBlock, iterations); @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) float eventMs = 1.0f; HIPCHECK (hipEventElapsedTime(&eventMs, start, stop)); float hostMs = HipTest::elapsed_time(hostStart, hostStop); - + printf ("host_time (gettimeofday) =%6.3fms\n", hostMs); printf ("kernel_time (hipEventElapsedTime) =%6.3fms\n", eventMs); printf ("\n"); diff --git a/projects/hip/tests/src/hipArray.cpp b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp similarity index 87% rename from projects/hip/tests/src/hipArray.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipArray.cpp index 9f9875a8d2..b31973e3d2 100644 --- a/projects/hip/tests/src/hipArray.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp @@ -1,6 +1,28 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + /* HIT_START - * BUILD: %t %s test_common.cpp EXCLUDE_HIP_PLATFORM nvcc - * RUN: %t EXCLUDE_HIP_PLATFORM + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM all + * RUN: %t * HIT_END */ @@ -170,7 +192,7 @@ void memcpyArraytest_size(size_t maxElem=0, size_t offset=0) maxElem = free/sizeof(T)/5; } - printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0, offset); // Test 1D diff --git a/projects/hip/tests/src/hipHostGetFlags.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp similarity index 96% rename from projects/hip/tests/src/hipHostGetFlags.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp index a58ba7aa43..9fad60aec8 100644 --- a/projects/hip/tests/src/hipHostGetFlags.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipHostMalloc.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp similarity index 98% rename from projects/hip/tests/src/hipHostMalloc.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp index d1950f825f..d6b3b05a1d 100644 --- a/projects/hip/tests/src/hipHostMalloc.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp @@ -21,7 +21,7 @@ */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp new file mode 100644 index 0000000000..8cf0979261 --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -0,0 +1,160 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t --tests 0x1 + * RUN: %t --tests 0x2 + * RUN: %t --tests 0x4 + * HIT_END + */ + +// TODO - bug if run both back-to-back, once fixed should just need one command line + +#include"test_common.h" +#include + +__global__ void Inc(hipLaunchParm lp, float *Ad){ + int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; + Ad[tx] = Ad[tx] + float(1); +} + + +template +void doMemCopy(size_t numElements, int offset, T *A, T *Bh, T *Bd, bool internalRegister) +{ + A = A + offset; + numElements -= offset; + + size_t sizeBytes = numElements * sizeof(T); + + if (internalRegister) { + HIPCHECK(hipHostRegister(A, sizeBytes, 0)); + } + + + // Reset + for(size_t i=0;iOFFSETS_TO_TRY); + + if (p_tests & 0x2) { + for (size_t i=0; i -__global__ void Inc(hipLaunchParm lp, float *Ad){ -int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; -Ad[tx] = Ad[tx] + float(1); -} +struct { + float a; + int b; + void *c; +} Struct ; int main(){ - float *A, **Ad; - int num_devices; - HIPCHECK(hipGetDeviceCount(&num_devices)); - Ad = new float*[num_devices]; - const size_t size = N * sizeof(float); - A = (float*)malloc(size); - HIPCHECK(hipHostRegister(A, size, 0)); - for(int i=0;i +class DeviceMemory +{ +public: + DeviceMemory(size_t numElements); + ~DeviceMemory(); + + T *A_d() const { return _A_d + _offset; }; + T *B_d() const { return _B_d + _offset; }; + T *C_d() const { return _C_d + _offset; }; + T *C_dd() const { return _C_dd + _offset; }; + + size_t maxNumElements() const { return _maxNumElements; }; + + + void offset(int offset) { _offset = offset; }; + int offset() const { return _offset; }; + +private: + T * _A_d; + T* _B_d; + T* _C_d; + T* _C_dd; + + + size_t _maxNumElements; + int _offset; +}; + +template +DeviceMemory::DeviceMemory(size_t numElements) + : _maxNumElements(numElements), + _offset(0) +{ + T ** np = nullptr; + HipTest::initArrays (&_A_d, &_B_d, &_C_d, np, np, np, numElements, 0); + + + size_t sizeElements = numElements * sizeof(T); + + + HIPCHECK ( hipMalloc(&_C_dd, sizeElements) ); +} + + +template +DeviceMemory::~DeviceMemory () +{ + T * np = nullptr; + HipTest::freeArrays (_A_d, _B_d, _C_d, np, np, np, 0); + + HIPCHECK (hipFree(_C_dd)); + + _C_dd = NULL; +}; + + + +//------- +template +class HostMemory +{ +public: + HostMemory(size_t numElements, bool usePinnedHost); + void reset(size_t numElements, bool full=false) ; + ~HostMemory(); + + + T *A_h() const { return _A_h + _offset; }; + T *B_h() const { return _B_h + _offset; }; + T *C_h() const { return _C_h + _offset; }; + + + + size_t maxNumElements() const { return _maxNumElements; }; + + void offset(int offset) { _offset = offset; }; + int offset() const { return _offset; }; +public: + + // Host arrays, secondary copy + T * A_hh; + T* B_hh; + + bool _usePinnedHost; +private: + size_t _maxNumElements; + + int _offset; + + // Host arrays + T * _A_h; + T* _B_h; + T* _C_h; +}; + +template +HostMemory::HostMemory(size_t numElements, bool usePinnedHost) + : _maxNumElements(numElements), + _usePinnedHost(usePinnedHost), + _offset(0) +{ + T ** np = nullptr; + HipTest::initArrays (np, np, np, &_A_h, &_B_h, &_C_h, numElements, usePinnedHost); + + A_hh = NULL; + B_hh = NULL; + + + size_t sizeElements = numElements * sizeof(T); + + if (usePinnedHost) { + HIPCHECK ( hipHostMalloc((void**)&A_hh, sizeElements, hipHostMallocDefault) ); + HIPCHECK ( hipHostMalloc((void**)&B_hh, sizeElements, hipHostMallocDefault) ); + } else { + A_hh = (T*)malloc(sizeElements); + B_hh = (T*)malloc(sizeElements); + } + +} + + +template +void +HostMemory::reset(size_t numElements, bool full) +{ + // Initialize the host data: + for (size_t i=0; i +HostMemory::~HostMemory () +{ + HipTest::freeArraysForHost (_A_h, _B_h, _C_h, _usePinnedHost); + + if (_usePinnedHost) { + HIPCHECK (hipHostFree(A_hh)); + HIPCHECK (hipHostFree(B_hh)); + + } else { + free(A_hh); + free(B_hh); + } + T *A_hh = NULL; + T *B_hh = NULL; + +}; @@ -52,71 +210,57 @@ void printSep() // IN: useMemkindDefault : If true, use memkinddefault (runtime figures out direction). if false, use explicit memcpy direction. // template -void memcpytest2(size_t numElements, bool usePinnedHost, bool useHostToHost, bool useDeviceToDevice, bool useMemkindDefault) +void memcpytest2(DeviceMemory *dmem, HostMemory *hmem, size_t numElements, bool useHostToHost, bool useDeviceToDevice, bool useMemkindDefault) { size_t sizeElements = numElements * sizeof(T); - printf ("test: %s<%s> size=%lu (%6.2fMB) usePinnedHost:%d, useHostToHost:%d, useDeviceToDevice:%d, useMemkindDefault:%d\n", + printf ("test: %s<%s> size=%lu (%6.2fMB) usePinnedHost:%d, useHostToHost:%d, useDeviceToDevice:%d, useMemkindDefault:%d, offsets:dev:%+d host:+%d\n", __func__, TYPENAME(T), sizeElements, sizeElements/1024.0/1024.0, - usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault); + hmem->_usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault, + dmem->offset(), hmem->offset() + ); - T *A_d, *B_d, *C_d; - T *A_h, *B_h, *C_h; - - - HipTest::initArrays (&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, numElements, usePinnedHost); + hmem->reset(numElements); unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, numElements); - T *A_hh = NULL; - T *B_hh = NULL; - T *C_dd = NULL; + assert (numElements <= dmem->maxNumElements()); + assert (numElements <= hmem->maxNumElements()); if (useHostToHost) { - if (usePinnedHost) { - HIPCHECK ( hipHostMalloc((void**)&A_hh, sizeElements, hipHostMallocDefault) ); - HIPCHECK ( hipHostMalloc((void**)&B_hh, sizeElements, hipHostMallocDefault) ); - } else { - A_hh = (T*)malloc(sizeElements); - B_hh = (T*)malloc(sizeElements); - } - - // Do some extra host-to-host copies here to mix things up: - HIPCHECK ( hipMemcpy(A_hh, A_h, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); - HIPCHECK ( hipMemcpy(B_hh, B_h, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); + HIPCHECK ( hipMemcpy(hmem->A_hh, hmem->A_h(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); + HIPCHECK ( hipMemcpy(hmem->B_hh, hmem->B_h(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); - HIPCHECK ( hipMemcpy(A_d, A_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); - HIPCHECK ( hipMemcpy(B_d, B_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->A_d(), hmem->A_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->B_d(), hmem->B_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); } else { - HIPCHECK ( hipMemcpy(A_d, A_h, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); - HIPCHECK ( hipMemcpy(B_d, B_h, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->A_d(), hmem->A_h(), sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->B_d(), hmem->B_h(), sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); } - hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, A_d, B_d, C_d, numElements); + hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, dmem->A_d(), dmem->B_d(), dmem->C_d(), numElements); if (useDeviceToDevice) { - HIPCHECK ( hipMalloc(&C_dd, sizeElements) ); + // Do an extra device-to-device copy here to mix things up: + HIPCHECK ( hipMemcpy(dmem->C_dd(), dmem->C_d(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyDeviceToDevice)); - // Do an extra device-to-device copies here to mix things up: - HIPCHECK ( hipMemcpy(C_dd, C_d, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyDeviceToDevice)); + //Destroy the original dmem->C_d(): + HIPCHECK ( hipMemset(dmem->C_d(), 0x5A, sizeElements)); - //Destroy the original C_d: - HIPCHECK ( hipMemset(C_d, 0x5A, sizeElements)); - - HIPCHECK ( hipMemcpy(C_h, C_dd, sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); + HIPCHECK ( hipMemcpy(hmem->C_h(), dmem->C_dd(), sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); } else { - HIPCHECK ( hipMemcpy(C_h, C_d, sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); + HIPCHECK ( hipMemcpy(hmem->C_h(), dmem->C_d(), sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); } HIPCHECK ( hipDeviceSynchronize() ); - HipTest::checkVectorADD(A_h, B_h, C_h, numElements); + HipTest::checkVectorADD(hmem->A_h(), hmem->B_h(), hmem->C_h(), numElements); + - HipTest::freeArrays (A_d, B_d, C_d, A_h, B_h, C_h, usePinnedHost); printf (" %s success\n", __func__); } @@ -129,11 +273,15 @@ void memcpytest2_for_type(size_t numElements) { printSep(); + DeviceMemory memD(numElements); + HostMemory memU(numElements, 0/*usePinnedHost*/); + HostMemory memP(numElements, 1/*usePinnedHost*/); + for (int usePinnedHost =0; usePinnedHost<=1; usePinnedHost++) { for (int useHostToHost =0; useHostToHost<=1; useHostToHost++) { // TODO for (int useDeviceToDevice =0; useDeviceToDevice<=1; useDeviceToDevice++) { for (int useMemkindDefault =0; useMemkindDefault<=1; useMemkindDefault++) { - memcpytest2(numElements, usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault); + memcpytest2(&memD, usePinnedHost ? &memP : &memU, numElements, useHostToHost, useDeviceToDevice, useMemkindDefault); } } } @@ -144,7 +292,7 @@ void memcpytest2_for_type(size_t numElements) //--- //Try many different sizes to memory copy. template -void memcpytest2_sizes(size_t maxElem=0, size_t offset=0) +void memcpytest2_sizes(size_t maxElem=0) { printSep(); printf ("test: %s<%s>\n", __func__, TYPENAME(T)); @@ -159,14 +307,68 @@ void memcpytest2_sizes(size_t maxElem=0, size_t offset=0) maxElem = free/sizeof(T)/5; } - printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", - deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0, offset); + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB\n", + deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0); + HIPCHECK ( hipDeviceReset() ); + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 1/*usePinnedHost*/); - for (size_t elem=64; elem+offset<=maxElem; elem*=2) { - HIPCHECK ( hipDeviceReset() ); - memcpytest2(elem+offset, 0, 1, 1, 0); // unpinned host - HIPCHECK ( hipDeviceReset() ); - memcpytest2(elem+offset, 1, 1, 1, 0); // pinned host + for (size_t elem=1; elem<=maxElem; elem*=2) { + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host + } +} + + +//--- +//Try many different sizes to memory copy. +template +void memcpytest2_offsets(size_t maxElem, bool devOffsets, bool hostOffsets) +{ + printSep(); + printf ("test: %s<%s>\n", __func__, TYPENAME(T)); + + int deviceId; + HIPCHECK(hipGetDevice(&deviceId)); + + size_t free, total; + HIPCHECK(hipMemGetInfo(&free, &total)); + + + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB\n", + deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0); + HIPCHECK ( hipDeviceReset() ); + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 1/*usePinnedHost*/); + + size_t elem = maxElem / 2; + + for (int offset=0; offset < 512; offset++) { + assert (elem + offset < maxElem); + if (devOffsets) { + memD.offset(offset); + } + if (hostOffsets) { + memU.offset(offset); + memP.offset(offset); + } + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host + } + + for (int offset=512; offset < elem; offset*=2) { + assert (elem + offset < maxElem); + if (devOffsets) { + memD.offset(offset); + } + if (hostOffsets) { + memU.offset(offset); + memP.offset(offset); + } + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host } } @@ -178,13 +380,17 @@ void multiThread_1(bool serialize, bool usePinnedHost) { printSep(); printf ("test: %s<%s> serialize=%d usePinnedHost=%d\n", __func__, TYPENAME(T), serialize, usePinnedHost); - std::thread t1 (memcpytest2,N, usePinnedHost,0,0,0); + DeviceMemory memD(N); + HostMemory mem1(N, usePinnedHost); + HostMemory mem2(N, usePinnedHost); + + std::thread t1 (memcpytest2, &memD, &mem1, N, 0,0,0); if (serialize) { t1.join(); } - std::thread t2 (memcpytest2,N, usePinnedHost,0,0,0); + std::thread t2 (memcpytest2,&memD, &mem2, N, 0,0,0); if (serialize) { t2.join(); } @@ -218,37 +424,39 @@ int main(int argc, char *argv[]) if (p_tests & 0x2) { - // Some tests around the 64MB boundary which have historically shown issues: - printf ("\n\n=== tests&0x2 (64MB boundary)\n"); -#if 0 + // Some tests around the 64KB boundary which have historically shown issues: + printf ("\n\n=== tests&0x2 (64KB boundary)\n"); + size_t maxElem = 32*1024*1024; + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 0/*usePinnedHost*/); // These all pass: - memcpytest2(15*1024*1024, 1, 0, 0, 0); - memcpytest2(16*1024*1024, 1, 0, 0, 0); - memcpytest2(16*1024*1024+16*1024, 1, 0, 0, 0); -#endif + memcpytest2(&memD, &memP, 15*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 16*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 16*1024*1024+16*1024, 0, 0, 0); + // Just over 64MB: - memcpytest2(16*1024*1024+512*1024, 1, 0, 0, 0); - memcpytest2(17*1024*1024+1024, 1, 0, 0, 0); - memcpytest2(32*1024*1024, 1, 0, 0, 0); - memcpytest2(32*1024*1024, 0, 0, 0, 0); - memcpytest2(32*1024*1024, 1, 1, 1, 0); - memcpytest2(32*1024*1024, 1, 1, 1, 0); + memcpytest2(&memD, &memP, 16*1024*1024+512*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 17*1024*1024+1024, 0, 0, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memU, 32*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 1, 1, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 1, 1, 0); + + } + if (p_tests & 0x4) { - printf ("\n\n=== tests&4 (test sizes and offsets)\n"); + printf ("\n\n=== tests&4 (test sizes)\n"); HIPCHECK ( hipDeviceReset() ); + memcpytest2_sizes(0); printSep(); - memcpytest2_sizes(0,0); - printSep(); - memcpytest2_sizes(0,64); - printSep(); - memcpytest2_sizes(1024*1024, 13); - printSep(); - memcpytest2_sizes(1024*1024, 50); } + + if (p_tests & 0x8) { printf ("\n\n=== tests&8\n"); HIPCHECK ( hipDeviceReset() ); @@ -270,6 +478,27 @@ int main(int argc, char *argv[]) } + if (p_tests & 0x10) { + printf ("\n\n=== tests&0x10 (test device offsets)\n"); + HIPCHECK ( hipDeviceReset() ); + size_t maxSize = 256*1024; + memcpytest2_offsets (maxSize, true, false); + memcpytest2_offsets (maxSize, true, false); + memcpytest2_offsets(maxSize, true, false); + } + + + if (p_tests & 0x20) { + printf ("\n\n=== tests&0x10 (test device offsets)\n"); + HIPCHECK ( hipDeviceReset() ); + size_t maxSize = 256*1024; + memcpytest2_offsets (maxSize, false, true); + memcpytest2_offsets (maxSize, false, true); + memcpytest2_offsets(maxSize, false, true); + } + + + passed(); } diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp index 4d7af21c72..7f19db559d 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp @@ -1,3 +1,27 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * HIT_END + */ + #include"test_common.h" #define SIZE 1024*1024 diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp index 1f7599491a..0a256d6362 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp @@ -56,5 +56,15 @@ int main(){ HIPCHECK_API(hipFree(NULL) , hipSuccess); HIPCHECK_API(hipHostFree(NULL) , hipSuccess); + + { + // Some negative testing - request a too-big allocation and verify it fails: + // Someday when we support virtual memory may need to refactor these: + size_t tooBig = 128LL*1024*1024*1024*1024; // 128 TB; + void *p; + HIPCHECK_API ( hipMalloc(&p, tooBig), hipErrorMemoryAllocation ); + HIPCHECK_API ( hipHostMalloc(&p, tooBig), hipErrorMemoryAllocation ); + } + passed(); } diff --git a/projects/hip/tests/src/hipRandomMemcpyAsync.cpp b/projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp similarity index 98% rename from projects/hip/tests/src/hipRandomMemcpyAsync.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp index 8a5067ac8d..9a5636c24b 100644 --- a/projects/hip/tests/src/hipRandomMemcpyAsync.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipTestMemcpyPin.cpp b/projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp similarity index 97% rename from projects/hip/tests/src/hipTestMemcpyPin.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp index 3ac4e09765..c6634ebbbb 100644 --- a/projects/hip/tests/src/hipTestMemcpyPin.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp similarity index 75% rename from projects/hip/tests/src/hipModule.cpp rename to projects/hip/tests/src/runtimeApi/module/hipModule.cpp index d9193cd87f..1b7b62cff2 100644 --- a/projects/hip/tests/src/hipModule.cpp +++ b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp @@ -22,13 +22,15 @@ THE SOFTWARE. #include #include #include +#include +#include #include "test_common.h" #define LEN 64 #define SIZE LEN<<2 -#define fileName "vcpy_isa.co" +#define fileName "vcpy_kernel.code" #define kernel_name "hello_world" __global__ void Cpy(hipLaunchParm lp, float *Ad, float* Bd){ @@ -44,7 +46,6 @@ int main(){ for(uint32_t i=0;iargBuffer(5); + memcpy(&argBuffer[3], &Ad, sizeof(void*)); + memcpy(&argBuffer[4], &Bd, sizeof(void*)); - std::vectorargBuffer(2); - memcpy(&argBuffer[0], &Ad, sizeof(void*)); - memcpy(&argBuffer[1], &Bd, sizeof(void*)); + size_t size = argBuffer.size()*sizeof(void*); - size_t size = argBuffer.size()*sizeof(void*); - - void *config[] = { + void *config[] = { HIP_LAUNCH_PARAM_BUFFER_POINTER, &argBuffer[0], HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END - }; + }; - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); + hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); - HIPCHECK(hipStreamDestroy(stream)); + HIPCHECK(hipStreamDestroy(stream)); HIPCHECK(hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost)); for(uint32_t i=0;i vec(1024*1024*64); + for(unsigned i=0;i<1024*1024*64;i++) { + hipFunction_t func; + hipModuleGetFunction(&func, Module, kernel_name); + vec[i] = func; + } + passed(); return 0; } - diff --git a/projects/hip/tests/src/hipModuleUnload.cpp b/projects/hip/tests/src/runtimeApi/module/hipModuleUnload.cpp similarity index 100% rename from projects/hip/tests/src/hipModuleUnload.cpp rename to projects/hip/tests/src/runtimeApi/module/hipModuleUnload.cpp diff --git a/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.code b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.code new file mode 100755 index 0000000000..4fd6472496 Binary files /dev/null and b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.code differ diff --git a/projects/hip/include/hip/hcc_detail/hcc_acc.h b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp similarity index 64% rename from projects/hip/include/hip/hcc_detail/hcc_acc.h rename to projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp index c36acc52f5..0375eee342 100644 --- a/projects/hip/include/hip/hcc_detail/hcc_acc.h +++ b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp @@ -20,27 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HCC_ACC_H -#define HCC_ACC_H -#include "hip/hip_runtime_api.h" +#include "hip/hip_runtime.h" -#if __cplusplus -#ifdef __HCC__ -#include -/** - * @brief Return hc::accelerator associated with the specified deviceId - * @return #hipSuccess, #hipErrorInvalidDevice - */ -hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); +extern "C" __global__ void hello_world(hipLaunchParm lp, float *a, float *b) +{ + int tx = hipThreadIdx_x; + b[tx] = a[tx]; +} -/** - * @brief Return hc::accelerator_view associated with the specified stream - * - * If stream is 0, the accelerator_view for the default stream is returned. - * @return #hipSuccess - */ -hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); -#endif -#endif - -#endif diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp index 7c83211f14..35b546e484 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp @@ -1,5 +1,5 @@ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN_NAMED: %t hipMultiThreadDevice-serial --tests 0x1 * RUN_NAMED: %t hipMultiThreadDevice-pyramid --tests 0x4 * RUN_NAMED: %t hipMultiThreadDevice-nearzero --tests 0x10 @@ -33,7 +33,7 @@ void createThenDestroyStreams(int iterations, int burstSize) } } - delete streams; + delete[] streams; } diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp index 3ea3489e20..229ceea440 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp index 6f431d0bb4..43a3e9bdea 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp b/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp index a7cace0ebe..4e343121ed 100644 --- a/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp +++ b/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include #include"test_common.h" +#include"hip/math_functions.h" const int NN = 1 << 21; @@ -31,7 +32,7 @@ __global__ void kernel(hipLaunchParm lp, float *x, float *y, int n){ int tid = hipThreadIdx_x; if(tid < 1){ for(int i=0;i #include"test_common.h" +#include"hip/math_functions.h" const int NN = 1 << 21; @@ -33,7 +34,7 @@ __global__ void kernel(hipLaunchParm lp, float *x, float *y, int n){ int tid = hipThreadIdx_x; if(tid < 1){ for(int i=0;i -#include -#include - -#define LEN 64 -#define SIZE LEN<<2 - -#ifdef __HIP_PLATFORM_HCC__ -#define fileName "vcpy_isa.co" -#endif - -#ifdef __HIP_PLATFORM_NVCC__ -#define fileName "vcpy_isa.ptx" -#endif - -#define kernel_name "hello_world" - -int main(){ - float *A, *B; - hipDeviceptr_t Ad, Bd; - A = new float[LEN]; - B = new float[LEN]; - - for(uint32_t i=0;iargBuffer(2); - memcpy(&argBuffer[0], &Ad, sizeof(void*)); - memcpy(&argBuffer[1], &Bd, sizeof(void*)); - - size_t size = argBuffer.size()*sizeof(void*); - - void *config[] = { - HIP_LAUNCH_PARAM_BUFFER_POINTER, &argBuffer[0], - HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, - HIP_LAUNCH_PARAM_END - }; - - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config); - - hipMemcpyDtoH(B, Bd, SIZE); - for(uint32_t i=0;i; - .reg .b32 %r<2>; - .reg .b64 %rd<8>; - - - ld.param.u64 %rd1, [hello_world_param_0]; - ld.param.u64 %rd2, [hello_world_param_1]; - cvta.to.global.u64 %rd3, %rd2; - cvta.to.global.u64 %rd4, %rd1; - mov.u32 %r1, %tid.x; - mul.wide.s32 %rd5, %r1, 4; - add.s64 %rd6, %rd4, %rd5; - ld.global.f32 %f1, [%rd6]; - add.s64 %rd7, %rd3, %rd5; - st.global.f32 [%rd7], %f1; - ret; -} - -