diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 1168b65be2..9ebbd3325f 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) @@ -158,7 +158,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 -I/opt/rocm/libhsakmt/include") # Set compiler and compiler flags set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc") @@ -175,23 +176,33 @@ 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/env.cpp) set(SOURCE_FILES_DEVICE src/device_util.cpp src/hip_ldg.cpp src/hip_fp16.cpp - src/device_functions.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 -Wl,-rpath ${HCC_HOME}/lib") + 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") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc c++ c++abi hc_am) + target_link_libraries(hip_hcc PRIVATE hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc_static c++ c++abi hc_am) + 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) @@ -216,7 +227,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) @@ -235,6 +246,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 ############################# diff --git a/projects/hip/CONTRIBUTING.md b/projects/hip/CONTRIBUTING.md index 81c4bc8c32..d9d353681d 100644 --- a/projects/hip/CONTRIBUTING.md +++ b/projects/hip/CONTRIBUTING.md @@ -126,7 +126,7 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl - 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. 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/bin/hccgenco.sh b/projects/hip/bin/hccgenco.sh index dcedfa174d..a7b4177624 100755 --- a/projects/hip/bin/hccgenco.sh +++ b/projects/hip/bin/hccgenco.sh @@ -46,17 +46,15 @@ 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 +mv dump* $hipgenisa_dir 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/dump-fiji.hsaco | 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/dump-fiji.hsaco $OUTPUT_FILE rm $hipgenisa_files rm -r $hipgenisa_dir diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index de8f0cb9a3..0dccb9bbc1 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -70,6 +70,11 @@ 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; + if ($HIP_PLATFORM eq "hcc") { $HSA_PATH=$ENV{'HSA_PATH'} // "/opt/rocm/hsa"; @@ -92,6 +97,8 @@ if ($HIP_PLATFORM eq "hcc") { $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,50 +106,25 @@ 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++"; } } $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 .= " -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"; - } - # 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. if ($HIP_ATP_MARKER) { @@ -157,8 +139,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) { @@ -222,7 +202,8 @@ if($HIP_PLATFORM eq "hcc"){ 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"){ @@ -261,9 +242,24 @@ foreach $arg (@ARGV) $HIPCXXFLAGS .= " -stdlib=libc++"; $setStdLib = 1; } + 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(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; $setStdLib = 1; } @@ -322,6 +318,36 @@ foreach $arg (@ARGV) $toolArgs .= " $arg" unless $swallowArg; } +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_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) + { + $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; + $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + +} + if ($hasC and $HIP_PLATFORM eq 'nvcc') { $HIPCXXFLAGS .= " -x cu"; } @@ -334,7 +360,6 @@ if ($buildDeps and $HIP_PLATFORM eq 'nvcc') { if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc') { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; } @@ -374,7 +399,8 @@ 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 (); } 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..4735f2b8dc 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,117 @@ | `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. | +| enum | `cudaComputeMode` | | CUDA device compute modes. | +| enum | `cudaDeviceAttr` | `hipDeviceAttribute_t` | CUDA device attributes. | +| enum | `cudaError` | `hipError_t` | CUDA Error types. | +| enum | `cudaError_t` | `hipError_t` | CUDA Error types. | +| enum | `cudaFuncCache` | `hipFuncCache_t` | CUDA function cache configurations. | +| enum | `cudaGraphicsCubeFace` | | CUDA graphics interop array indices for cube maps. | +| enum | `cudaGraphicsMapFlags` | | CUDA graphics interop map flags. | +| enum | `cudaGraphicsRegisterFlags` | | CUDA graphics interop register flags. | +| enum | `cudaMemcpyKind` | `hipMemcpyKind` | CUDA memory copy types. | +| enum | `cudaMemoryType` | `hipMemoryType` | CUDA memory types. | +| enum | `cudaOutputMode` | | CUDA Profiler Output modes. | +| enum | `cudaResourceType` | | CUDA resource types. | +| enum | `cudaResourceViewFormat` | | CUDA texture resource view formats. | +| enum | `cudaSharedMemConfig` | `hipSharedMemConfig` | CUDA shared memory configuration. | +| enum | `cudaSurfaceBoundaryMode` | | CUDA Surface boundary modes. | +| enum | `cudaSurfaceFormatMode` | | CUDA Surface format modes. | +| enum | `cudaTextureAddressMode` | | CUDA texture address modes. | +| enum | `cudaTextureFilterMode` | `hipTextureFilterMode` | CUDA texture filter modes. | +| enum | `cudaTextureReadMode` | `hipTextureReadMode` | CUDA texture read modes. | +| 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 output file modes. | +| 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 | `cudaEventBlockingSync` | `hipEventBlockingSync` | Event uses blocking synchronization. | +| 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..3274ed5b5c --- /dev/null +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -0,0 +1,46 @@ +# HIP Bugs + + + +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#errors-related-to-undefined-reference-to-hclaunchkernel__grid_launch_parm) +- [Application hangs after a hipLaunchKernel call](#what-if-i-see-application-hangs-after-a-hiplaunchkernel-call) + + + +### 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_ + +To workaround, try: +- Avoid calling hcLaunchKernel from a function with the __host__ attribute +__host__ MyFunc(…) { +hipLaunchKernel(myKernel, …) +- Avoid use of static with kernel definition: +static __global__ MyKernel +- Avoid defining kernels in anonymous namespace +namespace { +__global__ MyKernel … +- Avoid calling member functions + + +### What if I see application hangs after a hipLaunchKernel call? +If hipLaunchKernel takes parameters that request explicitly memcpy, then it will cause application hang. +Reason is that the hipLaunchKernel macro locks the stream. +If kernel paramters are actually function calls which invoke other hip apis (i.e. memcpy) to the same stream, then deadlock occurs. + +To workaround, try: +Move the function calls so they occur outside the hipLaunchKernel macro, store results in temps, then use the tems inside the kernel. + +``` +// Example pseudo code causing system hang: +// "bottom[0]->gpu_data()" calls hipMemcpy() implicitly and using the same stream, cause deadlock condition. +hipLaunchKernel(HIP_KERNEL_NAME(LRNComputeDiff),dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, + bottom[0]->gpu_data()); + +// Move "gpu_data()" ouside of hipLaunchKernel to avoid hang. +auto bot_gpu_data = bottom[0]->gpu_data(); +hipLaunchKernel( LRNComputeDiff, dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, + bot_gpu_data); + +``` \ No newline at end of file diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 0b79976988..d7235c4ebc 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -50,7 +50,7 @@ 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 @@ -75,13 +75,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: @@ -105,8 +105,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 compilation 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) @@ -130,47 +130,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. +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. @@ -183,9 +183,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. @@ -197,7 +197,7 @@ Sometimes this isn't what you want - you can force HIP to recognize the platform 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. @@ -206,7 +206,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 @@ -217,10 +217,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); 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 5093291baa..f51f53a092 100644 --- a/projects/hip/docs/markdown/hip_porting_driver_api.md +++ b/projects/hip/docs/markdown/hip_porting_driver_api.md @@ -1,7 +1,7 @@ # 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. @@ -90,14 +90,14 @@ the context. The current context is implicitly used by other APIs such as `hipS 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. +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 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`. +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. diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index e0e74c0f89..e34bed0cbc 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -553,7 +553,7 @@ If you pass a ".cu" file, hcc will attempt to compile it as a Cuda language file ### HIP Environment Variables -On the HCC path, HIP provides a number of environment variables that control the behavior of HIP. Some of these are useful for appliction development (for example HIP_VISIBLE_DEVICES, HIP_LAUNCH_BLOCKING), +On the HCC path, HIP provides a number of environment variables that control the behavior of HIP. Some of these are useful for application development (for example HIP_VISIBLE_DEVICES, HIP_LAUNCH_BLOCKING), some are useful for performance tuning or experimentation (for example HIP_STAGING*), and some are useful for debugging (HIP_DB). You can see the environment variables supported by HIP as well as their current values and usage with the environment var "HIP_PRINT_ENV" - set this and then run any HIP application. For example: diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 61f1bbcfbc..463c9c13b3 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -92,11 +92,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 +131,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 +185,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 +273,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 +315,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. @@ -349,7 +349,8 @@ These options cause HCC to serialize. Useful if you have libraries or code whic $32 = {_shortTid = 1, _apiSeqNum = 803} ``` -- HCC tracks all of the application memory allocations, including those from HIP and HC's "am_alloc". These can be printed by calling the function 'hc::am_memtracker_print()'. +- 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'): @@ -361,4 +362,68 @@ 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/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/README.md b/projects/hip/hipify-clang/README.md index 6e58f719b7..850dfb3ffa 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -48,6 +48,16 @@ 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 ``` +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: + +```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. diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 938c980684..fd4c35d34b 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -77,6 +77,9 @@ enum ConvTypes { CONV_ERR, CONV_DEF, CONV_TEX, + CONV_GL, + CONV_GRAPHICS, + CONV_SURFACE, CONV_OTHER, CONV_INCLUDE, CONV_INCLUDE_CUDA_MAIN_H, @@ -87,10 +90,11 @@ enum ConvTypes { }; const char *counterNames[CONV_LAST] = { - "driver", "dev", "mem", "kern", "coord_func", "math_func", - "special_func", "stream", "event", "occupancy", "ctx", "module", - "cache", "err", "def", "tex", "other", "include", - "include_cuda_main_header", "type", "literal", "numeric_literal"}; + "driver", "dev", "mem", "kern", "coord_func", "math_func", + "special_func", "stream", "event", "occupancy", "ctx", "module", + "cache", "err", "def", "tex", "gl", "graphics", + "surface", "other", "include", "include_cuda_main_header", "type", + "literal", "numeric_literal"}; enum ApiTypes { API_DRIVER = 0, @@ -184,138 +188,142 @@ 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_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}; + 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 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["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["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; + 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_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_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorNotInitialized", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; - 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}; + cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; 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}; - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; + 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_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_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_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_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_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_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_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; ///////////////////////////// CUDA DRIVER API ///////////////////////////// + // 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_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; @@ -429,7 +437,11 @@ struct cuda2hipMap { // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_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, HIP_UNSUPPORTED}; @@ -449,16 +461,14 @@ struct cuda2hipMap { 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}; - cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"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}; - + // 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}; @@ -469,15 +479,6 @@ struct cuda2hipMap { // Driver cuda2hipRename["cuDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_DRIVER}; - // Occupancy - // unsupported yet by HIP - cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - 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}; - // Context cuda2hipRename["cuCtxCreate_v2"] = {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}; cuda2hipRename["cuCtxDestroy_v2"] = {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}; @@ -506,14 +507,23 @@ 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, HIP_UNSUPPORTED}; + 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["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}; + cuda2hipRename["cuEventCreate"] = {"hipEventCreate", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventDestroy_v2"] = {"hipEventDestroy", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}; @@ -615,51 +625,111 @@ struct cuda2hipMap { cuda2hipRename["PATCH_LEVEL"] = {"hipLibraryPatchVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 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}; + 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}; - // 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}; + // 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 + 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}; + 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}; // 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}; @@ -693,46 +763,55 @@ 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["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; @@ -834,18 +913,25 @@ struct cuda2hipMap { 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}; // 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}; + cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; // unsupported yet by HIP - cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDeviceMapHost"] = {"hipDeviceMapHost", CONV_DEV, API_RUNTIME}; @@ -854,30 +940,58 @@ struct cuda2hipMap { 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}; + + // Execution control + // CUDA function cache configurations + cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", 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}; + // Execution control functions + // unsupported yet by HIP + cuda2hipRename["cudaFuncGetAttributes"] = {"hipFuncGetAttributes", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaFuncSetSharedMemConfig"] = {"hipFuncSetSharedMemConfig", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetParameterBuffer"] = {"hipGetParameterBuffer", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForDevice"] = {"hipSetDoubleForDevice", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForHost"] = {"hipSetDoubleForHost", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Execution Control [deprecated since 7.0] + // unsupported yet by HIP + cuda2hipRename["cudaConfigureCall"] = {"hipConfigureCall", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLaunch"] = {"hipLaunch", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetupArgument"] = {"hipSetupArgument", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; // Driver/Runtime cuda2hipRename["cudaDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, 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}; + cuda2hipRename["cudaIpcMemLazyEnablePeerAccess"] = {"hipIpcMemLazyEnablePeerAccess", CONV_ERR, API_RUNTIME}; // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -907,18 +1021,92 @@ struct cuda2hipMap { // Profiler // unsupported yet by HIP - cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; - 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}; + cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; + cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - // Channel descriptor - cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + + // Texture Reference Management + 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}; + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + 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}; + + // Texture Object Management + // unsupported yet by HIP + 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}; + + // 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}; //---------------------------------------BLAS-------------------------------------// // Blas types @@ -1692,18 +1880,56 @@ StringRef unquoteStr(StringRef s) { class Cuda2Hip { public: - Cuda2Hip(Replacements *R): Replace(R) {} - + 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"; + } + } 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; @@ -1757,10 +1983,12 @@ protected: if (!counter.unsupported) { SourceLocation sl = start.getLocWithOffset(begin + 1); Replacement Rep(SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, SM); + insertReplacement(Rep, fullSL); } } else { - // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [string literal].\n"; + // std::string msg = "the following reference is not handled: '" + name.str() + "' [string literal]."; + // printHipifyMessage(SM, start, msg); } if (end == StringRef::npos) { break; @@ -1774,8 +2002,8 @@ class Cuda2HipCallback; class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks, public Cuda2Hip { public: - HipifyPPCallbacks(Replacements *R) - : Cuda2Hip(R), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} + HipifyPPCallbacks(Replacements *R, const std::string &mainFileName) + : Cuda2Hip(R, mainFileName), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { Preprocessor &PP = CI.getPreprocessor(); @@ -1813,7 +2041,8 @@ public: const char *E = _sm->getCharacterData(sle); SmallString<128> tmpData; Replacement Rep(*_sm, sl, E - B, Twine("<" + repName + ">").toStringRef(tmpData)); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; @@ -1840,7 +2069,8 @@ public: << "will be replaced with: " << repName << "\n" << "SourceLocation: " << sl.printToString(*_sm) << "\n"); Replacement Rep(*_sm, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro].\n"; @@ -1895,7 +2125,8 @@ public: sl = sl_macro; } Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; @@ -1915,7 +2146,8 @@ public: StringRef repName = found->second.hipName; sl = sl_macro; Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; @@ -1970,19 +2202,20 @@ private: } DEBUG(dbgs() << "initial paramlist: " << initialParamList << "\n" << "new paramlist: " << OS.str() << "\n"); Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); - Replace->insert(Rep0); + FullSourceLoc fullSL(sl, *(Result.SourceManager)); + insertReplacement(Rep0, fullSL); } 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()) { if (!found->second.unsupported) { - 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)) { @@ -2002,13 +2235,15 @@ private: if (bReplace) { updateCounters(found->second, name.str()); Replacement Rep(*SM, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { updateCounters(found->second, name.str()); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [function call].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [function call]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2031,8 +2266,7 @@ private: dyn_cast(e)) { calleeName = ule->getName().getAsIdentifierInfo()->getName(); owner->addMatcher(functionTemplateDecl(hasName(calleeName)) - .bind("unresolvedTemplateName"), - this); + .bind("unresolvedTemplateName"), this); } } XStr.clear(); @@ -2078,8 +2312,9 @@ private: launchKernel->getLocEnd(), 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchKernel->getLocStart()); Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); - Replace->insert(Rep); - hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; + FullSourceLoc fullSL(launchKernel->getLocStart(), *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; updateCounters(counter, refName.str()); return true; } @@ -2092,6 +2327,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_"); @@ -2103,13 +2340,13 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = threadIdx->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [builtin].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [builtin]."; + printHipifyMessage(*SM, sl, msg); } } } @@ -2121,18 +2358,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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = enumConstantRef->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant ref]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2148,18 +2387,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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = enumConstantDecl->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2174,18 +2415,20 @@ 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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = typedefVar->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2196,6 +2439,9 @@ private: if (const VarDecl *typedefVarPtr = Result.Nodes.getNodeAs("cudaTypedefVarPtr")) { const Type *t = typedefVarPtr->getType().getTypePtrOrNull(); if (t) { + SourceManager *SM = Result.SourceManager; + TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); QualType QT = t->getPointeeType(); QT = QT.getUnqualifiedType(); StringRef name = QT.getAsString(); @@ -2204,15 +2450,14 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2222,23 +2467,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()) { - updateCounters(found->second, name.str()); - if (!found->second.unsupported) { - StringRef repName = found->second.hipName; - TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + 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; + 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); } - } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var].\n"; } return true; } @@ -2249,20 +2498,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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2273,22 +2524,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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = typeInfo->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct sizeof]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2327,8 +2584,9 @@ private: StringRef varName = sharedVar->getNameAsString(); StringRef repName = Twine("HIP_DYNAMIC_SHARED(" + typeName + ", " + varName + ")").toStringRef(tmpData); Replacement Rep(*SM, slStart, repLength, repName); - Replace->insert(Rep); - hipCounter counter = {"HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME}; + FullSourceLoc fullSL(slStart, *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = { "HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME }; updateCounters(counter, refName.str()); } } @@ -2345,19 +2603,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()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2368,6 +2628,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() @@ -2378,14 +2641,13 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2415,8 +2677,8 @@ private: } public: - Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks) - : Cuda2Hip(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); } @@ -2439,15 +2701,7 @@ public: 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); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(PP, *Result.SourceManager); } private: @@ -2456,14 +2710,7 @@ private: }; 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); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(Match, *_sm); } } // end anonymous namespace @@ -2473,7 +2720,7 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac 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_"))))) @@ -2545,7 +2792,7 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac int64_t printStats(const std::string &csvFile, const std::string &srcFile, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback, - uint64_t replacedBytes, uint64_t totalBytes, + 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; @@ -2578,10 +2825,25 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, str = "TOTAL bytes"; llvm::outs() << " " << str << ": " << totalBytes << "\n"; csv << str << separator << totalBytes << "\n"; - str = "CODE CHANGED %"; - conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); - llvm::outs() << " " << str << ": " << conv << "%\n"; - csv << str << separator << conv << "%\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"; @@ -2660,7 +2922,7 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, } void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles, - uint64_t replacedBytes, uint64_t totalBytes, + 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; @@ -2699,10 +2961,24 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve str = "TOTAL bytes"; llvm::outs() << " " << str << ": " << totalBytes << "\n"; csv << str << separator << totalBytes << "\n"; - str = "CODE CHANGED %"; - conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); - llvm::outs() << " " << str << ": " << conv << "%\n"; - csv << str << separator << conv << "%\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"; @@ -2794,10 +3070,12 @@ int main(int argc, const char **argv) { } else { csv = "hipify_stats.csv"; } - size_t filesTransleted = fileSources.size(); + size_t filesTranslated = fileSources.size(); uint64_t repBytesTotal = 0; uint64_t bytesTotal = 0; - if (PrintStats && filesTransleted > 1) { + unsigned changedLinesTotal = 0; + unsigned linesTotal = 0; + if (PrintStats && filesTranslated > 1) { std::remove(csv.c_str()); } for (const auto & src : fileSources) { @@ -2828,8 +3106,8 @@ int main(int argc, const char **argv) { } RefactoringTool Tool(OptionsParser.getCompilations(), dst); ast_matchers::MatchFinder Finder; - HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); - Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks); + HipifyPPCallbacks PPCallbacks(&Tool.getReplacements(), src); + Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks, src); addAllMatchers(Finder, &Callback); @@ -2853,6 +3131,8 @@ int main(int argc, const char **argv) { 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()) { @@ -2860,10 +3140,12 @@ int main(int argc, const char **argv) { 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(); } - SourceManager Sources(Diagnostics, Tool.getFiles()); - Rewriter Rewrite(Sources, DefaultLangOptions); + Rewriter Rewrite(SM, DefaultLangOptions); if (!Tool.applyAllReplacements(Rewrite)) { DEBUG(dbgs() << "Skipped some replacements.\n"); } @@ -2886,17 +3168,19 @@ int main(int argc, const char **argv) { } std::remove(csv.c_str()); } - if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes, start)) { - filesTransleted--; + 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 (PrintStats && fileSources.size() > 1) { - printAllStats(csv, fileSources.size(), filesTransleted, repBytesTotal, bytesTotal, begin); + printAllStats(csv, fileSources.size(), filesTranslated, repBytesTotal, bytesTotal, changedLinesTotal, linesTotal, begin); } 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..af8875e256 --- /dev/null +++ b/projects/hip/include/hip/channel_descriptor.h @@ -0,0 +1,36 @@ +/* +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. +*/ + +#pragma once + +// 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 diff --git a/projects/hip/include/hip/driver_types.h b/projects/hip/include/hip/driver_types.h new file mode 100644 index 0000000000..a4010d6b4e --- /dev/null +++ b/projects/hip/include/hip/driver_types.h @@ -0,0 +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. +*/ + +#pragma once + +#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 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..85689438e2 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -0,0 +1,382 @@ +/* +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. +*/ + +#ifndef HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define 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_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index e2b061c640..212f22d5dc 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -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,15 +23,579 @@ THE SOFTWARE. #include #include -__device__ float __int_as_float (int x); -__device__ double __hiloint2double (int hi, int lo); + + + +// 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); -extern __device__ double __longlong_as_double(long long int x); -extern __device__ long long int __double_as_longlong(double x); #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..1fe72b0507 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/driver_types.h @@ -0,0 +1,41 @@ +/* +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. +*/ + +#ifndef HIP_HCC_DETAIL_DRIVER_TYPES_H +#define 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/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index f4af5839ad..d4fea7f034 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-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,11 +20,162 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIPCOMPLEX_H -#define HIPCOMPLEX_H +#ifndef INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#define INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -typedef float2 hipFloatComplex; -typedef double2 hipDoubleComplex; +#include "./hip_fp16.h" +#include "./hip_vector_types.h" + +#if __cplusplus +#define COMPLEX_ADD_OP_OVERLOAD(type) \ +__device__ __host__ static 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 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 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 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 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__ static inline float hipCrealf(hipFloatComplex z){ return z.x; diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index e4408556f1..b28f92d451 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-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,8 +20,8 @@ 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_HCC_DETAIL_FP16_H +#define HIP_HCC_DETAIL_FP16_H #include "hip/hip_runtime.h" @@ -36,66 +36,211 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; -struct holder{ - union { - __half h; - unsigned short s; - }; -}; +typedef __half half; +typedef __half2 half2; -#define HINF 65504 +/* +Half Arithmetic Functions +*/ +__device__ __half __hadd(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); -static struct holder hInf = {HINF}; +/* +Half2 Arithmetic Functions +*/ -extern "C" __half __hip_hc_ir_hadd_half(__half, __half); -extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); -extern "C" __half __hip_hc_ir_hmul_half(__half, __half); -extern "C" __half __hip_hc_ir_hsub_half(__half, __half); +__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 Comparision Functions +*/ + +__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 Comparision Functions +*/ + +__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 Math Functions +*/ + +__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); + +/* +Half2 Math Functions +*/ + +__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); + +/* +Half Conversion And Data Movement +*/ + +__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, 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); -__device__ static inline __half __hadd(const __half a, const __half b) { - return __hip_hc_ir_hadd_half(a, b); -} +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"); -__device__ static inline __half __hadd_sat(__half a, __half b) { - return __hip_hc_ir_hadd_half(a, b); -} - -__device__ static inline __half __hfma(__half a, __half b, __half c) { - return __hip_hc_ir_hfma_half(a, b, c); -} - -__device__ static inline __half __hfma_sat(__half a, __half b, __half c) { - return __hip_hc_ir_hfma_half(a, b, c); -} - -__device__ static inline __half __hmul(__half a, __half b) { - return __hip_hc_ir_hmul_half(a, b); -} - -__device__ static inline __half __hmul_sat(__half a, __half b) { - return __hip_hc_ir_hmul_half(a, b); -} - -__device__ static inline __half __hneg(__half a) { - return -a; -} - -__device__ static inline __half __hsub(__half a, __half b) { - return __hip_hc_ir_hsub_half(a, b); -} - -__device__ static inline __half __hsub_sat(__half a, __half b) { - return __hip_hc_ir_hsub_half(a, b); -} - -__device__ static inline __half hdiv(__half a, __half b) { - return a/b; -} +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 @@ -163,70 +308,165 @@ __device__ static inline __half2 h2div(__half2 a, __half2 b) { 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); +} /* -Half comparision Functions +__device__ static inline __half hrcp(const __half h) { + return __hip_hc_ir_hrcp_half(h); +} */ - -__device__ static inline bool __heq(__half a, __half b) { - return a == b ? true : false; +__device__ static inline __half hrint(const __half h) { + return __hip_hc_ir_hrint_half(h); } -__device__ static inline bool __hge(__half a, __half b) { - return a >= b ? true : false; +__device__ static inline __half hrsqrt(const __half h) { + return __hip_hc_ir_hrsqrt_half(h); } -__device__ static inline bool __hgt(__half a, __half b) { - return a > b ? true : false; +__device__ static inline __half hsin(const __half h) { + return __hip_hc_ir_hsin_half(h); } -__device__ static inline bool __hisinf(__half a) { - return a == hInf.s ? true : false; +__device__ static inline __half hsqrt(const __half a) { + return __hip_hc_ir_hsqrt_half(a); } -__device__ static inline bool __hisnan(__half a) { - return a > hInf.s ? true : false; -} - -__device__ static inline bool __hle(__half a, __half b) { - return a <= b ? true : false; -} - -__device__ static inline bool __hlt(__half a, __half b) { - return a < b ? true : false; -} - -__device__ static inline bool __hne(__half a, __half b) { - return a != b ? true : false; +__device__ static inline __half htrunc(const __half a) { + return __hip_hc_ir_htrunc_half(a); } /* -Half2 Comparision Functions +Half2 Math Operations */ -__device__ static inline bool __hbeq2(__half2 a, __half2 b) { - return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false); +__device__ static inline __half2 h2ceil(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2ceil_int(h.q); + return a; } -__device__ static inline bool __hbge2(__half2 a, __half2 b) { - return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false); +__device__ static inline __half2 h2cos(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2cos_int(h.q); + return a; } -__device__ static inline bool __hbgt2(__half2 a, __half2 b) { - return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false); +__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 bool __hble2(__half2 a, __half2 b) { - return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false); +__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 bool __hblt2(__half2 a, __half2 b) { - return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false); +__device__ static inline __half2 h2exp2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2exp2_int(h.q); + return a; } -__device__ static inline bool __hbne2(__half2 a, __half2 b) { - return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); +__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 @@ -243,8 +483,6 @@ typedef struct __attribute__((aligned(4))){ } __half2; - - #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f747b446d7..98c3ada969 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -26,8 +26,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_H -#define HIP_RUNTIME_H +#ifndef HIP_HCC_DETAIL_RUNTIME_H +#define HIP_HCC_DETAIL_RUNTIME_H //--- // Top part of file can be compiled with any compiler @@ -69,6 +69,9 @@ extern int HIP_TRACE_API; #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__ @@ -121,206 +124,6 @@ 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; @@ -418,26 +221,7 @@ __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); @@ -468,252 +252,6 @@ __host__ __device__ int max(int arg1, int arg2); __device__ __attribute__((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 @@ -739,6 +277,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. * @@ -749,7 +291,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. @@ -761,7 +305,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. @@ -807,14 +353,31 @@ __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, 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, void* src, size_t size) +{ + return __hip_hc_memcpy(dst, src, size); +} + +static inline __device__ void* memset(void* ptr, uint8_t val, size_t size) +{ + return __hip_hc_memset(ptr, val, size); +} + #define __syncthreads() hc_barrier(CLK_LOCAL_MEM_FENCE) 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 4c9cedecc4..2c75b584c4 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-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,8 +21,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_API_H -#define HIP_RUNTIME_API_H +#ifndef HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#define 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. @@ -30,9 +30,11 @@ THE SOFTWARE. #include #include +#include #include #include +#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); @@ -71,14 +73,7 @@ typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; typedef struct ihipModule_t *hipModule_t; -struct ihipModuleSymbol_t{ - uint64_t _object; // The kernel object. - uint32_t _groupSegmentSize; - uint32_t _privateSegmentSize; - char _name[64]; // TODO - review for performance cost. Name is just used for debug. -}; - -typedef struct ihipModuleSymbol_t hipFunction_t; +typedef struct ihipModuleSymbol_t *hipFunction_t; typedef void* hipDeviceptr_t; @@ -176,6 +171,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; @@ -364,7 +365,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); /** @@ -510,12 +511,10 @@ const char *hipGetErrorString(hipError_t hipError); * @{ * * The following Stream APIs are not (yet) supported in HIP: - * - cudaStreamAddCallback * - cudaStreamAttachMemAsync * - cudaStreamCreateWithPriority * - cudaStreamGetPriority - * - cudaStreamWaitEvent - */ + */ /** @@ -1160,7 +1159,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t siz */ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); - +hipError_t hipMemcpyFromSymbolAsync(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); /** * @brief Copy data from src to dst asynchronously. @@ -1234,6 +1233,88 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st **/ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; + +/** + * @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 /** * @} @@ -1910,6 +1991,87 @@ hipError_t hipIpcCloseMemHandle(void *devPtr); } /* extern "c" */ #endif +#ifdef __cplusplus +/* + * @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 +/** + * @} + */ + + +#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..d60f66ddc2 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-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 @@ -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 e15da69b3f..cd5a09215a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1131,23 +1131,23 @@ struct longlong4 { } __attribute__((aligned(32))); #define DECLOP_MAKE_ONE_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x) { \ + struct type ret; \ ret.x = x; \ return ret; \ } #define DECLOP_MAKE_TWO_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x, comp y) { \ + struct type ret; \ ret.x = x; \ ret.y = y; \ return ret; \ } #define DECLOP_MAKE_THREE_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y, comp z) { \ - type ret; \ +__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; \ @@ -1155,8 +1155,8 @@ __device__ __host__ static inline type make_##type(comp x, comp y, comp z) { \ } #define DECLOP_MAKE_FOUR_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y, comp z, comp w) { \ - type ret; \ +__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; \ @@ -1228,20 +1228,20 @@ DECLOP_MAKE_FOUR_COMPONENT(signed long, longlong4); #if __cplusplus #define DECLOP_1VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__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 type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ return ret; \ @@ -1260,7 +1260,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_1VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ val.x op; \ @@ -1273,7 +1273,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_1VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type& rhs) { \ +__device__ __host__ static inline type operator op(type& rhs) { \ type ret; \ ret.x = op rhs.x; \ return ret; \ @@ -1289,7 +1289,7 @@ __device__ __host__ static inline bool operator op (type& rhs) { \ */ #define DECLOP_2VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__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; \ @@ -1297,14 +1297,14 @@ __device__ __host__ static type operator op (const type& lhs, const type& rhs) { } #define DECLOP_2VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__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 type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1326,7 +1326,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_2VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1341,7 +1341,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_2VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1359,7 +1359,7 @@ __device__ __host__ static inline bool operator op (type &rhs) { \ */ #define DECLOP_3VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__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; \ @@ -1368,7 +1368,7 @@ __device__ __host__ static type operator op (const type& lhs, const type& rhs) { } #define DECLOP_3VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1376,7 +1376,7 @@ __device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1401,7 +1401,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_3VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1418,7 +1418,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_3VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1437,7 +1437,7 @@ __device__ __host__ static inline bool operator op (type &rhs) { \ */ #define DECLOP_4VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op ( const type& lhs, const type& rhs) { \ +__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; \ @@ -1447,7 +1447,7 @@ __device__ __host__ static type operator op ( const type& lhs, const type& rhs) } #define DECLOP_4VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1456,7 +1456,7 @@ __device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1484,7 +1484,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_4VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1503,7 +1503,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_4VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 906c39421e..e401cb24f3 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -35,7 +35,7 @@ THE SOFTWARE. #define __host__ __attribute__((cpu)) #define __device__ __attribute__((hc)) -#define __global__ __attribute__((hc_grid_launch)) +#define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) #define __noinline__ __attribute__((noinline)) #define __forceinline__ __attribute__((always_inline)) 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..2cc4ef81bd --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -0,0 +1,263 @@ +/* +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. +*/ + +#ifndef HIP_HCC_DETAIL_MATH_FUNCTIONS_H +#define 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__ 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..107b5d26c1 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -0,0 +1,42 @@ +/* +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. +*/ + + +#ifndef HIP_HCC_DETAIL_TEXTURE_TYPES_H +#define 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/math_functions.h b/projects/hip/include/hip/math_functions.h new file mode 100644 index 0000000000..6afe463a5d --- /dev/null +++ b/projects/hip/include/hip/math_functions.h @@ -0,0 +1,36 @@ +/* +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. +*/ + +#pragma once + +// 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 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..8502745968 --- /dev/null +++ b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h @@ -0,0 +1,25 @@ +/* +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. +*/ + +#pragma once + +#include"channel_descriptor.h" 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 7df6706186..f5e7960d45 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-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 @@ -85,6 +85,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 +219,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)); } @@ -321,6 +333,18 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* return hipCUDAErrorTohipError(cudaMemcpyToSymbolAsync(symbol, src, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(copyType))); } +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()); } diff --git a/projects/hip/include/hip/texture_types.h b/projects/hip/include/hip/texture_types.h new file mode 100644 index 0000000000..2561e12eb5 --- /dev/null +++ b/projects/hip/include/hip/texture_types.h @@ -0,0 +1,30 @@ +/* +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. +*/ + +#pragma once + +#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 diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 18314a9b6d..64c0d54caf 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -5,7 +5,7 @@ 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) ############################# # Packaging steps diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 3c863b8b76..0073c1399a 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) const unsigned threadsPerBlock = 256; printf ("info: launch 'vector_square' kernel\n"); - hipLaunchKernel(HIP_KERNEL_NAME(vector_square), dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); + hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); printf ("info: copy Device2Host\n"); CHECK ( hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); diff --git a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp index 9c07d066ba..0add1ce3e3 100644 --- a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp +++ b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp @@ -23,7 +23,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/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/device_functions.cpp b/projects/hip/src/device_functions.cpp index 0de0cf7f6b..abc9db570e 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -18,39 +18,576 @@ THE SOFTWARE. */ #include +#include +#include +#include +#include "device_util.h" -extern "C" float __hip_int_as_float(int); +struct holder64Bit{ + union{ + double d; + unsigned long int uli; + signed long int sli; + signed int si[2]; + unsigned int ui[2]; + }; +} __attribute__((aligned(8))); -typedef struct { - signed int hi; - signed int lo; -} __hip_signed_2; +struct holder32Bit { + union { + float f; + unsigned int ui; + signed int si; + }; +} __attribute__((aligned(4))); -typedef struct { -union { - double d; - long long int lli; - __hip_signed_2 s2; -} ; -} __hip_64bit_struct; +struct holder64Bit hold64; +struct holder32Bit hold32; -typedef struct { -union { - float f; - unsigned int ui; - signed int si; -}; -} __hip_32bit_struct; - -__device__ float __int_as_float (int x) { - __hip_32bit_struct s; - s.si = x; - return s.f; +__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__ double __hiloint2double (int hi, int lo) { - __hip_64bit_struct s; - s.s2.hi = hi; - s.s2.lo = lo; - return s.d; + +__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 db0f494af4..fb207e3996 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. #include #include #include "device_util.h" - +#include "hip/hcc_detail/device_functions.h" #include "hip/hip_runtime.h" //================================================================================================= @@ -96,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.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; -} // loop unrolling -__device__ void* memcpy(void* dst, void* src, size_t size) +__device__ void* __hip_hc_memcpy(void* dst, void* src, size_t size) { uint8_t *dstPtr, *srcPtr; dstPtr = (uint8_t*)dst; @@ -172,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; @@ -182,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; @@ -942,735 +837,6 @@ __device__ float __hip_ynf(int n, float x) -__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); -} - -__device__ long long __double_as_longlong(double x) -{ - return static_cast(x); -} - __device__ void __threadfence_system(void){ // no-op } @@ -2800,185 +1846,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..90d00feac0 --- /dev/null +++ b/projects/hip/src/env.cpp @@ -0,0 +1,91 @@ +#include "hip_hcc.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/hip_device.cpp b/projects/hip/src/hip_device.cpp index 131526b6e2..3cefca82e7 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -189,7 +189,7 @@ hipError_t ihipDeviceSetState(void) e = hipSuccess; } - return ihipLogStatus(e); + return e; } @@ -261,13 +261,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) @@ -287,7 +287,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) e = hipErrorInvalidDevice; } - return ihipLogStatus(e); + return e; } hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 83e0a161c7..b306a9d3de 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,6 +22,513 @@ THE SOFTWARE. #include"hip/hip_fp16.h" +struct hipHalfHolder{ + union { + __half h; + unsigned short s; + }; +}; + +#define HINF 65504 + +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}; static const __half __half_value_zero_float = {0x0}; @@ -375,4 +882,6 @@ __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 a2383245fc..a119ea1c54 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -46,6 +46,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "hip_hcc.h" #include "trace_helper.h" +#include "env.h" #ifndef USE_COPY_EXT_V2 @@ -85,6 +86,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. @@ -92,6 +94,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; + @@ -338,6 +346,7 @@ void ihipStream_t::locked_wait() }; // 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); @@ -1032,166 +1041,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; tidgetDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + 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)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + throw ihipException(hipErrorRuntimeOther); + } } } @@ -1874,6 +1780,35 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) +{ + if(kind == hipMemcpyHostToHost){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyHostToHost); + } + if(kind == hipMemcpyHostToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes); + } + if(kind == hipMemcpyDeviceToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToDevice); + } + if(kind == hipMemcpyDeviceToHost){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToHost); + } +} + +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) +{ + if(kind == hipMemcpyHostToDevice) { + hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); + hc::am_memtracker_add(dst, dstPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } + if(kind == hipMemcpyDeviceToHost) { + hc::AmPointerInfo srcPtrInfo(NULL, src, sizeBytes, acc, true, false); + hc::am_memtracker_add(src, srcPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } +} void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) { @@ -1956,9 +1891,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 diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 031c92fca7..d7d92a221c 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -26,7 +26,10 @@ THE SOFTWARE. #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) @@ -35,7 +38,6 @@ THE SOFTWARE. #define USE_IPC 0 - //--- // Environment variables: @@ -62,7 +64,10 @@ 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. @@ -179,54 +184,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(...)\ -{\ - tls_tidInfo.incApiSeqNum();\ - 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(...)\ - tls_tidInfo.incApiSeqNum(); -#endif - - -// Just initialize the HIP runtime, but don't log any trace information. -#define HIP_INIT()\ - std::call_once(hip_initialized, ihipInit);\ - ihipCtxStackUpdate(); -#define HIP_SET_DEVICE()\ - ihipDeviceSetState(); - -// 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_tidInfo.tid(),tls_tidInfo.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 //--- @@ -238,12 +200,14 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); #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, @@ -270,6 +234,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 { @@ -314,7 +343,7 @@ public: std::string fileName; void *ptr; size_t size; - + std::list funcTrack; ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} }; @@ -450,8 +479,6 @@ private: typedef ihipStreamCriticalBase_t ihipStreamCritical_t; typedef LockedAccessor LockedAccessor_StreamCrit_t; - - //--- // Internal stream structure. class ihipStream_t { @@ -465,10 +492,10 @@ public: // 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, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); //--- // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll deleted file mode 100644 index 52460a38bb..0000000000 --- a/projects/hip/src/hip_ir.ll +++ /dev/null @@ -1,89 +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 linkonce_odr spir_func void @__threadfence() #1 { - fence syncscope(2) seq_cst - ret void -} - -define linkonce_odr spir_func void @__threadfence_block() #1 { - fence syncscope(3) seq_cst - ret void -} - -; Lightning does not support inline asm for 16-bit data types -; So, bitcast half to short and then extend to 32bit i32 -; After inline asm, convert back to half -define half @__hip_hc_ir_hadd_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_add_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hsub_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_sub_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hmul_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_mul_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hfma_half(half %a, half %b, half %c) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = bitcast half %c to i16 - %4 = zext i16 %1 to i32 - %5 = zext i16 %2 to i32 - %6 = zext i16 %3 to i32 - %7 = tail call i32 asm "v_mad_f16 $0, $1, $2, $3","=v,v,v,v"(i32 %4, i32 %5, i32 %6) - %8 = trunc i32 %7 to i16 - %9 = bitcast i16 %8 to half - ret half %9 -} - -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 -} - -attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index c43b6991c6..cb265159ba 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -160,10 +160,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) { @@ -216,6 +220,9 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) } } } + if (HIP_SYNC_HOST_ALLOC) { + hipDeviceSynchronize(); + } return ihipLogStatus(hip_status); } @@ -232,7 +239,7 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int 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; @@ -284,7 +291,7 @@ 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; @@ -431,7 +438,7 @@ hipError_t hipHostUnregister(void *hostPtr) hipError_t hipMemcpyToSymbol(const char* 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 +449,30 @@ 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(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) { - HIP_INIT_API(symbolName, src, count, offset, kind, stream); + HIP_INIT_CMD_API(symbolName, src, count, offset, kind, stream); if(symbolName == nullptr) { @@ -472,17 +485,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(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 +505,50 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ } return ihipLogStatus(e); +} +hipError_t hipMemcpyFromSymbolAsync(void* dst, const char* 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(symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, src); + + if(src == nullptr || dst == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + 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); @@ -520,7 +569,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind 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); @@ -541,7 +590,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) 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); @@ -562,7 +611,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) 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); @@ -583,7 +632,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte 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); @@ -634,7 +683,7 @@ hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyK 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 +692,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 +715,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 +741,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 +794,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); @@ -804,7 +853,7 @@ ihipMemsetKernel(hipStream_t stream, // 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; @@ -854,12 +903,12 @@ 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) { @@ -993,6 +1042,8 @@ hipError_t hipHostFree(void* ptr) return ihipLogStatus(hipStatus); }; + +// Deprecated: hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 7d77dbe8dd..f21adf9691 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -35,6 +35,23 @@ THE SOFTWARE. //TODO Use Pool APIs from HCC to get memory regions. + +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;\ @@ -201,6 +218,9 @@ hipError_t hipModuleUnload(hipModule_t hmod) { ret = hipErrorInvalidValue; } + for(std::list::iterator f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + delete *f; + } delete hmod; return ihipLogStatus(ret); } @@ -217,6 +237,14 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char ret = hipErrorInvalidContext; }else{ + std::string str(name); + for(std::list::iterator 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; @@ -230,20 +258,22 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, - &func->_object); + &sym->_object); CHECK_HSA(status, hipErrorNotFound); status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, - &func->_groupSegmentSize); + &sym->_groupSegmentSize); CHECK_HSA(status, hipErrorNotFound); status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, - &func->_privateSegmentSize); + &sym->_privateSegmentSize); CHECK_HSA(status, hipErrorNotFound); - strncpy(func->_name, name, sizeof(func->_name)); + sym->_name = name; + *func = sym; + hmod->funcTrack.push_back(*func); } return ihipLogStatus(ret); } @@ -297,8 +327,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, /* Kernel argument preparation. */ - grid_launch_parm lp; // TODO - dummy arg but values are printed during debug. - hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f._name); + grid_launch_parm lp; + lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name.c_str()); hsa_kernel_dispatch_packet_t aql; @@ -314,19 +345,25 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, aql.grid_size_x = blockDimX * gridDimX; aql.grid_size_y = blockDimY * gridDimY; aql.grid_size_z = blockDimZ * gridDimZ; - aql.group_segment_size = f._groupSegmentSize + sharedMemBytes; - aql.private_segment_size = f._privateSegmentSize; - aql.kernel_object = f._object; + 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); + 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); + }; + + lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); - ihipPostLaunchKernel(f._name, hStream, lp); + ihipPostLaunchKernel(f->_name.c_str(), hStream, lp); } return ihipLogStatus(ret); @@ -348,7 +385,7 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipFunction_t func; ihipModuleGetSymbol(&func, hmod, name); *bytes = PrintSymbolSizes(hmod->ptr, name) + sizeof(amd_kernel_code_t); - *dptr = reinterpret_cast(func._object); + *dptr = reinterpret_cast(func->_object); return ihipLogStatus(ret); } } diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp new file mode 100644 index 0000000000..a1ee9d3ce5 --- /dev/null +++ b/projects/hip/src/math_functions.cpp @@ -0,0 +1,1010 @@ + +/* +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(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__ 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) +{ + 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 -inline std::string ToString(hipFunction_t v) -{ - std::ostringstream ss; - ss << "0x" << std::hex << v._object; - return ss.str(); -}; - - - // hipStream_t template <> inline std::string ToString(hipStream_t v) 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 100% rename from projects/hip/tests/src/hipDrvGetPCIBusId.cpp rename to projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp 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/hipComplex.cpp b/projects/hip/tests/src/deviceLib/hipComplex.cpp similarity index 100% rename from projects/hip/tests/src/hipComplex.cpp rename to projects/hip/tests/src/deviceLib/hipComplex.cpp diff --git a/projects/hip/tests/src/hipDeviceMemcpy.cpp b/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipDeviceMemcpy.cpp rename to projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp index 330c4fc799..a3a302a3ef 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.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" @@ -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..6bf13a0809 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,36 @@ __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); } __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..476c5e0997 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -17,48 +17,68 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s + * RUN: %t + * HIT_END + */ + #include #include +#include"test_common.h" #include #define NUM 1024 #define SIZE 1024*4 #ifdef __HIP_PLATFORM_HCC__ -__attribute__((address_space(1))) int global[NUM]; +__attribute__((address_space(1))) int globalIn[NUM]; +__attribute__((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" -#include "hip/hip_fp16.h" -#define hInf 0x7C00 -#define hInfPK 0x7C007C00 -#define h65504 0xF7FF -#define h65504PK 0xF7FFF7FF -#define h27 0x4EC0 -#define h27PK 0x4EC04EC0 -#define h7 0x4700 -#define h7PK 0x47004700 -#define h3 0x4200 -#define h3PK 0x42004200 -#define h1 0x3C00 -#define h1PK 0x3C003C00 -#define hPoint5 0x3800 -#define hPoint5PK 0x38003800 -#define hZero 0x0000 -#define hNeg1 0xBC00 -#define hNeg1PK 0xBC00BC00 +#define LEN 64 +#define HALF_SIZE 64*sizeof(__half) +#define HALF2_SIZE 64*sizeof(__half2) -__global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){ - Out[0] = __hadd(In1[0], In2[0]); - Out[1] = __hadd_sat(In1[1], In2[1]); - Out[2] = __hfma(In1[2], In2[2],In3[2]); - Out[3] = __hfma_sat(In1[3], In2[3], In3[3]); - Out[4] = __hmul(In1[4], In2[4]); - Out[5] = __hmul_sat(In1[5], In2[5]); - Out[6] = __hneg(In1[6]); - Out[7] = __hsub(In1[7], In2[7]); - Out[8] = __hsub_sat(In1[8], In2[8]); - Out[9] = hdiv(In1[9], In2[9]); +#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 CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){ - Out[0] = __hadd2(In1[0], In2[0]); - Out[1] = __hadd2_sat(In1[1], In2[1]); - Out[2] = __hfma2(In1[2], In2[2],In3[2]); - Out[3] = __hfma2_sat(In1[3], In2[3], In3[3]); - Out[4] = __hmul2(In1[4], In2[4]); - Out[5] = __hmul2_sat(In1[5], In2[5]); - Out[6] = __hneg2(In1[6]); - Out[7] = __hsub2(In1[7], In2[7]); - Out[8] = __hsub2_sat(In1[8], In2[8]); - Out[9] = h2div(In1[9], In2[9]); +__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); } -__global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) { - Out[0] = __heq(In1[0], In2[0]); - Out[1] = __hge(In1[1], In2[1]); - Out[2] = __hgt(In1[2], In2[2]); - Out[3] = __hisinf(In1[3]); - Out[4] = __hisnan(In1[4]); - Out[5] = __hle(In1[5], In2[5]); - Out[6] = __hlt(In1[6], In2[6]); - Out[7] = __hne(In1[7], In2[7]); -} +#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 index 0e5757b30d..12a8cc76a3 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -20,29 +20,35 @@ 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 - -#define cmpFloat1(in, exp) \ +#include +#include"test_common.h" +#define cmpVal1(in, exp) \ if(in.x != exp) { \ std::cout<<"Failed at: "<<__LINE__<<" in func: "<<__func__<<" expected output: "<> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, 253); + 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; @@ -137,74 +202,147 @@ bool TestUChar2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, 253); + 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; @@ -232,19 +370,19 @@ bool TestUChar3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -252,9 +390,9 @@ bool TestUChar3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -263,49 +401,122 @@ bool TestUChar3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, 253); + 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; @@ -338,19 +549,19 @@ bool TestUChar4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -360,9 +571,9 @@ bool TestUChar4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -373,51 +584,126 @@ bool TestUChar4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, 253); + 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; @@ -442,73 +728,134 @@ bool TestUChar4() { return true; } + bool TestChar1() { char1 f1, f2, f3; f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (char)253); + 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; @@ -531,74 +878,147 @@ bool TestChar2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (char)253); + 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; @@ -626,19 +1046,19 @@ bool TestChar3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -646,9 +1066,9 @@ bool TestChar3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -657,49 +1077,123 @@ bool TestChar3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (char)253); + 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; @@ -732,19 +1226,19 @@ bool TestChar4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -754,9 +1248,9 @@ bool TestChar4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -767,51 +1261,126 @@ bool TestChar4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (char)253); + 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; @@ -836,73 +1405,134 @@ bool TestChar4() { return true; } + bool TestUShort1() { ushort1 f1, f2, f3; f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (unsigned short)65533); + 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; @@ -925,74 +1555,147 @@ bool TestUShort2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (unsigned short)65533); + 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; @@ -1020,19 +1723,19 @@ bool TestUShort3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1040,9 +1743,9 @@ bool TestUShort3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1051,49 +1754,123 @@ bool TestUShort3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (unsigned short)65533); + 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; @@ -1126,19 +1903,19 @@ bool TestUShort4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1148,9 +1925,9 @@ bool TestUShort4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1161,51 +1938,125 @@ bool TestUShort4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (unsigned short)65533); + 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; @@ -1230,73 +2081,134 @@ bool TestUShort4() { return true; } + bool TestShort1() { short1 f1, f2, f3; f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (signed short)65533); + 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; @@ -1319,74 +2231,148 @@ bool TestShort2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (signed short)65533); + 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; @@ -1414,19 +2400,19 @@ bool TestShort3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1434,9 +2420,9 @@ bool TestShort3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1445,49 +2431,122 @@ bool TestShort3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (signed short)65533); + 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; @@ -1520,19 +2579,19 @@ bool TestShort4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1542,9 +2601,9 @@ bool TestShort4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1555,51 +2614,126 @@ bool TestShort4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (signed short)65533); + 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; @@ -1630,68 +2764,128 @@ bool TestUInt1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (unsigned int)4294967293); + 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; @@ -1714,74 +2908,147 @@ bool TestUInt2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (unsigned int)4294967293); + 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; @@ -1809,19 +3076,19 @@ bool TestUInt3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1829,9 +3096,9 @@ bool TestUInt3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1840,49 +3107,123 @@ bool TestUInt3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (unsigned int)4294967293); + 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; @@ -1915,19 +3256,19 @@ bool TestUInt4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1937,9 +3278,9 @@ bool TestUInt4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1950,51 +3291,126 @@ bool TestUInt4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (unsigned int)4294967293); + 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; @@ -2019,73 +3435,134 @@ bool TestUInt4() { return true; } + bool TestInt1() { int1 f1, f2, f3; f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (signed int)4294967293); + 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; @@ -2108,74 +3585,147 @@ bool TestInt2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (signed int)4294967293); + 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; @@ -2203,19 +3753,19 @@ bool TestInt3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2223,9 +3773,9 @@ bool TestInt3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -2234,49 +3784,123 @@ bool TestInt3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (signed int)4294967293); + 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; @@ -2309,19 +3933,19 @@ bool TestInt4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2331,9 +3955,9 @@ bool TestInt4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -2344,51 +3968,126 @@ bool TestInt4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (signed int)4294967293); + 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; @@ -2413,73 +4112,632 @@ bool TestInt4() { 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; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, 18446744073709551613UL); + 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; @@ -2502,74 +4760,147 @@ bool TestULong2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, 18446744073709551613UL); + 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; @@ -2597,19 +4928,19 @@ bool TestULong3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2617,9 +4948,9 @@ bool TestULong3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -2628,49 +4959,123 @@ bool TestULong3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, 18446744073709551613UL); + 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; @@ -2703,19 +5108,19 @@ bool TestULong4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2725,9 +5130,9 @@ bool TestULong4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -2738,51 +5143,126 @@ bool TestULong4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, 18446744073709551613UL); + 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; @@ -2807,73 +5287,134 @@ bool TestULong4() { return true; } + bool TestLong1() { long1 f1, f2, f3; f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, -3); + 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; @@ -2896,74 +5437,147 @@ bool TestLong2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, -3); + 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; @@ -2991,19 +5605,19 @@ bool TestLong3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -3011,9 +5625,9 @@ bool TestLong3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -3022,49 +5636,123 @@ bool TestLong3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, -3); + 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; @@ -3097,19 +5785,19 @@ bool TestLong4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -3119,9 +5807,9 @@ bool TestLong4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -3132,51 +5820,126 @@ bool TestLong4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, -3); + 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; @@ -3202,46 +5965,102 @@ bool TestLong4() { } -bool TestFloat1() { - float1 f1, f2, f3; -// float1 f4(1); -// cmpFloat1(f4, 1.0f); -// float1 f5(2.0f); -// cmpFloat1(f5, 2.0f); - f1.x = 1.0f; - f2.x = 1.0f; +bool TestDouble1() { + double1 f1, f2, f3; + f1.x = 1.0; + f2.x = 1.0; f3 = f1 + f2; - cmpFloat1(f3, 2.0f); + cmpVal1(f3, 2.0); f2 = f3 - f1; - cmpFloat1(f2, 1.0f); + cmpVal1(f2, 1.0); f1 = f2 * f3; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1 / f3; - cmpFloat1(f2, 2.0f/2.0f); + cmpVal1(f2, 2.0/2.0); f1 += f2; - cmpFloat1(f1, 3.0f); + cmpVal1(f1, 3.0); f1 -= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 *= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 /= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1++; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 2.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 2.0); f2 = f1--; - cmpFloat1(f2, 3.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f2, 3.0); + cmpVal1(f1, 2.0); f2 = ++f1; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 3.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 3.0); f2 = --f1; - cmpFloat1(f1, 2.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0); + cmpVal1(f1, 2.0); - f1.x = 3.0f; - f2.x = 4.0f; - f3.x = 3.0f; + 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); @@ -3252,48 +6071,121 @@ bool TestFloat1() { return true; } -bool TestFloat2() { - float2 f1, f2, f3; - f1.x = 1.0f; - f1.y = 1.0f; - f2.x = 1.0f; - f2.y = 1.0f; +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; - cmpFloat2(f3, 2.0f); + cmpVal2(f3, 2.0); f2 = f3 - f1; - cmpFloat2(f2, 1.0f); + cmpVal2(f2, 1.0); f1 = f2 * f3; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1 / f3; - cmpFloat2(f2, 2.0f/2.0f); + cmpVal2(f2, 2.0f/2.0); f1 += f2; - cmpFloat2(f1, 3.0f); + cmpVal2(f1, 3.0); f1 -= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 *= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 /= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1++; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 2.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 2.0); f2 = f1--; - cmpFloat2(f2, 3.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f2, 3.0); + cmpVal2(f1, 2.0); f2 = ++f1; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 3.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 3.0); f2 = --f1; - cmpFloat2(f1, 2.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0); + cmpVal2(f1, 2.0); - f1.x = 3.0f; - f1.y = 3.0f; - f2.x = 4.0f; - f2.y = 4.0f; - f3.x = 3.0f; - f3.y = 3.0f; + 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); @@ -3305,51 +6197,125 @@ bool TestFloat2() { 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; +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; - cmpFloat3(f3, 2.0f); + cmpVal3(f3, 2.0); f2 = f3 - f1; - cmpFloat3(f2, 1.0f); + cmpVal3(f2, 1.0); f1 = f2 * f3; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0); f2 = f1 / f3; - cmpFloat3(f2, 2.0f/2.0f); + cmpVal3(f2, 2.0f/2.0); f1 += f2; - cmpFloat3(f1, 3.0f); + cmpVal3(f1, 3.0); f1 -= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 *= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 /= f2; f2 = f1++; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 2.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 2.0); f2 = f1--; - cmpFloat3(f2, 3.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f2, 3.0); + cmpVal3(f1, 2.0); f2 = ++f1; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 3.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 3.0); f2 = --f1; - cmpFloat3(f1, 2.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0); + cmpVal3(f1, 2.0); - 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; + 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); @@ -3361,57 +6327,131 @@ bool TestFloat3() { 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; +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; - cmpFloat4(f3, 2.0f); + cmpVal4(f3, 2.0); f2 = f3 - f1; - cmpFloat4(f2, 1.0f); + cmpVal4(f2, 1.0); f1 = f2 * f3; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0); f2 = f1 / f3; - cmpFloat4(f2, 2.0f/2.0f); + cmpVal4(f2, 2.0f/2.0); f1 += f2; - cmpFloat4(f1, 3.0f); + cmpVal4(f1, 3.0); f1 -= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 *= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 /= f2; f2 = f1++; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 2.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 2.0); f2 = f1--; - cmpFloat4(f2, 3.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f2, 3.0); + cmpVal4(f1, 2.0); f2 = ++f1; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 3.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 3.0); f2 = --f1; - cmpFloat4(f1, 2.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0); + cmpVal4(f1, 2.0); - 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; + 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); @@ -3423,6 +6463,1358 @@ bool TestFloat4() { } +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); @@ -3430,6 +7822,7 @@ int main() { 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() @@ -3437,7 +7830,9 @@ int main() { && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() && TestInt1() && TestInt2() && TestInt3() && TestInt4() && TestULong1() && TestULong2() && TestULong3() && TestULong4() - && TestLong1() && TestLong2() && TestLong3() && TestLong4() == true); - + && 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..87351a1e83 --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp @@ -0,0 +1,3880 @@ +/* +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"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; + hipLaunchKernel(CheckVectorTypes, dim3(1,1,1), dim3(1,1,1), 0, 0, ptr); + passed(); +} 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_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..9357e5211a 100644 --- a/projects/hip/tests/src/hipHcc.cpp +++ b/projects/hip/tests/src/hipHcc.cpp @@ -22,8 +22,8 @@ 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 */ 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..522572a191 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 * 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..0f6ebb4927 --- /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 + * 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..8f831bf5e0 100644 --- a/projects/hip/tests/src/hipArray.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp @@ -1,5 +1,27 @@ +/* +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 + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc * RUN: %t EXCLUDE_HIP_PLATFORM * 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 98% rename from projects/hip/tests/src/hipHostGetFlags.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp index a58ba7aa43..a989b879ac 100644 --- a/projects/hip/tests/src/hipHostGetFlags.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp @@ -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/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp similarity index 98% rename from projects/hip/tests/src/hipHostRegister.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index e9044d5a86..37ee9b1b78 100644 --- a/projects/hip/tests/src/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.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/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/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/tests/src/runtimeApi/module/vcpy_kernel.cpp b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp new file mode 100644 index 0000000000..0375eee342 --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp @@ -0,0 +1,30 @@ +/* +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 "hip/hip_runtime.h" + +extern "C" __global__ void hello_world(hipLaunchParm lp, float *a, float *b) +{ + int tx = hipThreadIdx_x; + b[tx] = a[tx]; +} + 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; -} - -