From a0cb435ab96d9569b62c844bfb1e6b4aed856b59 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 19 Dec 2016 17:36:07 -0800 Subject: [PATCH 001/104] fix spelling errors Conflicts: README.md docs/markdown/hip_faq.md Change-Id: I8ca025e01276939ed3d7be24200ecaa8cf5e1e2c [ROCm/hip commit: 65ad9d80d79d9eac96e2244e67c4726f36826aa0] --- projects/hip/CONTRIBUTING.md | 2 +- projects/hip/INSTALL.md | 6 +-- projects/hip/docs/markdown/hip_faq.md | 50 +++++++++---------- projects/hip/docs/markdown/hip_performance.md | 6 +-- .../docs/markdown/hip_porting_driver_api.md | 6 +-- .../hip/docs/markdown/hip_porting_guide.md | 2 +- projects/hip/docs/markdown/hip_profiling.md | 10 ++-- 7 files changed, 41 insertions(+), 41 deletions(-) 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/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..c198c4dc4b 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. From a3cd9893d32d424ab9bd8455485a24319fd3e59e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 13 Jan 2017 14:59:15 +0300 Subject: [PATCH 002/104] [HIPIFY] Formatting, no functional changes. [ROCm/hip commit: b7992fa252f414d5569dc10d0c943fd38a2d8700] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 241 ++++++++++----------- 1 file changed, 119 insertions(+), 122 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 938c980684..543d527d58 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -184,138 +184,137 @@ 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", 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 ///////////////////////////// // 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}; @@ -450,14 +449,6 @@ struct cuda2hipMap { cuda2hipRename["CUcontext"] = {"hipCtx_t", 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}; - cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; // Stream Flags cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; @@ -469,15 +460,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}; @@ -514,6 +496,14 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; // Events + 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}; + cuda2hipRename["cuEventCreate"] = {"hipEventCreate", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventDestroy_v2"] = {"hipEventDestroy", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}; @@ -720,19 +710,19 @@ struct cuda2hipMap { 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}; // 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}; @@ -872,12 +862,21 @@ struct cuda2hipMap { // unsupported yet by HIP cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // 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}; + // 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}; // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -1693,7 +1692,6 @@ StringRef unquoteStr(StringRef s) { class Cuda2Hip { public: Cuda2Hip(Replacements *R): Replace(R) {} - uint64_t countReps[CONV_LAST] = { 0 }; uint64_t countApiReps[API_LAST] = { 0 }; uint64_t countRepsUnsupported[CONV_LAST] = { 0 }; @@ -2031,8 +2029,7 @@ private: dyn_cast(e)) { calleeName = ule->getName().getAsIdentifierInfo()->getName(); owner->addMatcher(functionTemplateDecl(hasName(calleeName)) - .bind("unresolvedTemplateName"), - this); + .bind("unresolvedTemplateName"), this); } } XStr.clear(); From b00361b981d8225c8922bef3eee8b6112d017701 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 10:56:07 -0600 Subject: [PATCH 003/104] added half2 cmp and conv, data movement device functions 1. Added half2 comparision functions 2. Added conversion and data movement half apis Change-Id: Ia33c0e957d9deb1f2b7a8fde8e22168f4d41b88b [ROCm/hip commit: 3f52f76194cfd4c8e55a095711e71e946c908a94] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 391 +++++++++++++++++- .../hip/tests/src/deviceLib/hipTestHalf.cpp | 10 + 2 files changed, 397 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index e4408556f1..638cecefb4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,7 +36,7 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; -struct holder{ +struct hipHalfHolder{ union { __half h; unsigned short s; @@ -45,7 +45,7 @@ struct holder{ #define HINF 65504 -static struct holder hInf = {HINF}; +static struct hipHalfHolder __hInfValue = {HINF}; extern "C" __half __hip_hc_ir_hadd_half(__half, __half); extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); @@ -180,11 +180,11 @@ __device__ static inline bool __hgt(__half a, __half b) { } __device__ static inline bool __hisinf(__half a) { - return a == hInf.s ? true : false; + return a == __hInfValue.h ? true : false; } __device__ static inline bool __hisnan(__half a) { - return a > hInf.s ? true : false; + return a > __hInfValue.h ? true : false; } __device__ static inline bool __hle(__half a, __half b) { @@ -227,6 +227,389 @@ __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 __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __half2 __float22half2_rn(const float2 a) { + __half2 b; + b.p[0] = (__half)a.x; + b.p[1] = (__half)a.y; + return b; +} + +__device__ static inline __half __float2half(const float a) { + return (__half)a; +} + +__device__ static inline __half2 __float2half2_rn(const float a) { + __half2 b; + b.p[0] = (__half)a; + b.p[1] = (__half)a; + return b; +} + +__device__ static inline __half __float2half_rd(const float a) { + return (__half)a; +} + +__device__ static inline __half __float2half_ru(const float a) { + return (__half)a; +} + +__device__ static inline __half __float2half_rz(const float a) { + return (__half)a; +} + +__device__ static inline __half2 __floats2half2_rn(const float a, const float b) { + __half2 c; + c.p[0] = (__half)a; + c.p[1] = (__half)b; + return c; +} + +__device__ static inline float2 __half22float2(const __half2 a) { + float2 b; + b.x = (float)a.p[0]; + b.y = (float)a.p[1]; + return b; +} + +__device__ static inline float __half2float(const __half a) { + return (float)a; +} + +__device__ static inline __half2 half2half2(const __half a) { + __half2 b; + b.p[0] = a; + b.p[1] = a; + return b; +} + +__device__ static inline int __half2int_rd(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_rn(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_ru(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_rz(__half h) { + return (int)h; +} + +__device__ static inline long long int __half2ll_rd(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_rn(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_ru(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_rz(__half h) { + return (long long int)h; +} + +__device__ static inline short __half2short_rd(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_rn(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_ru(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_rz(__half h) { + return (short)h; +} + +__device__ static inline unsigned int __half2uint_rd(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_rn(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_ru(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_rz(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned long long int __half2ull_rd(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_rn(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_ru(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_rz(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned short int __half2ushort_rd(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_rn(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_ru(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_rz(__half h) { + return (unsigned short int)h; +} + +__device__ static inline short int __half_as_short(const __half h) { + hipHalfHolder hH; + hH.h = h; + return (short)hH.s; +} + +__device__ static inline unsigned short int __half_as_ushort(const __half h) { + hipHalfHolder hH; + hH.h = h; + return hH.s; +} + +__device__ static inline __half2 __halves2half2(const __half a, const __half b) { + __half2 c; + c.p[0] = a; + c.p[1] = b; + return c; +} + +__device__ static inline float __high2float(const __half2 a) { + return (float)a.p[1]; +} + +__device__ static inline __half __high2half(const __half2 a) { + return a.p[1]; +} + +__device__ static inline __half2 __high2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[1]; + return b; +} + +__device__ static inline __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__ static inline __half __int2half_rd(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_rn(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_ru(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_rz(int i) { + return (__half)i; +} + +__device__ static inline __half __ll2half_rd(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_rn(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_ru(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_rz(long long int i){ + return (__half)i; +} + +__device__ static inline float __low2float(const __half2 a) { + return (float)a.p[0]; +} + +__device__ static inline __half __low2half(const __half2 a) { + return a.p[0]; +} + +__device__ static inline __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__ static inline __half2 __low2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[0]; + b.p[1] = a.p[0]; + return b; +} + +__device__ static inline __half2 __lowhigh2highlow(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[0]; + return b; +} + +__device__ static inline __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__ static inline __half __short2half_rd(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_rn(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_ru(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_rz(short int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rd(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rn(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_ru(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rz(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rd(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rn(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_ru(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rz(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rd(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rn(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_ru(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rz(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort_as_half(const unsigned short int i) { + hipHalfHolder hH; + hH.s = i; + return hH.h; +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 46927c3902..05900259f1 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -86,6 +86,16 @@ __global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* O Out[7] = __hne(In1[7], In2[7]); } +__global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* Out) { + Out[0] = __heq2(In1[0], In2[0]); + Out[1] = __hge2(In1[1], In2[1]); + Out[2] = __hgt2(In1[2], In2[2]); + Out[4] = __hisnan2(In1[4]); + Out[5] = __hle2(In1[5], In2[5]); + Out[6] = __hlt2(In1[6], In2[6]); + Out[7] = __hne2(In1[7], In2[7]); +} + int main(){ } From 0d5b2539d35fbbe38b0e7999a0499eb3c51424a5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 12:05:29 -0600 Subject: [PATCH 004/104] added math functions for half 1. Added math functions for half precision 2. HRCP is not available due to device code linking errors, will be enabled once it is fixed 3. Added math functions to half test file Change-Id: Ie317ce70ef518a4fc3f27142143d01e0327f5df3 [ROCm/hip commit: 8c978c210ced06926a4fa38ec08401157e0806d7] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 72 +++++++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 15 ++++ 2 files changed, 87 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 638cecefb4..002fbdd3ce 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -57,6 +57,18 @@ extern "C" int __hip_hc_ir_hfma2_int(int, int, int); extern "C" int __hip_hc_ir_hmul2_int(int, int); extern "C" int __hip_hc_ir_hsub2_int(int, int); +extern "C" __half __hip_hc_ir_hceil_half(__half) __asm("llvm.ceil.f16"); +extern "C" __half __hip_hc_ir_hcos_half(__half) __asm("llvm.cos.f16"); +extern "C" __half __hip_hc_ir_hexp2_half(__half) __asm("llvm.exp2.f16"); +extern "C" __half __hip_hc_ir_hfloor_half(__half) __asm("llvm.floor.f16"); +extern "C" __half __hip_hc_ir_hlog2_half(__half) __asm("llvm.log2.f16"); +extern "C" __half __hip_hc_ir_hrcp_half(__half) __asm("llvm.amdgcn.rcp.f16"); +extern "C" __half __hip_hc_ir_hrint_half(__half) __asm("llvm.rint.f16"); +extern "C" __half __hip_hc_ir_hrsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_hsin_half(__half) __asm("llvm.sin.f16"); +extern "C" __half __hip_hc_ir_hsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_htrunc_half(__half) __asm("llvm.trunc.f16"); + __device__ static inline __half __hadd(const __half a, const __half b) { return __hip_hc_ir_hadd_half(a, b); } @@ -610,6 +622,66 @@ __device__ static inline __half __ushort_as_half(const unsigned short int i) { return hH.h; } +__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(__hip_hc_ir_hmul_half(h, 1.442694)); +} + +__device__ static inline __half hexp10(const __half h) { + return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(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 __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.693147); +} + +__device__ static inline __half hlog10(const __half h) { + return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.301029); +} + +__device__ static inline __half hlog2(const __half h) { + return __hip_hc_ir_hlog2_half(h); +} +/* +__device__ static inline __half hrcp(const __half h) { + return __hip_hc_ir_hrcp_half(h); +} +*/ +__device__ static inline __half hrint(const __half h) { + return __hip_hc_ir_hrint_half(h); +} + +__device__ static inline __half hrsqrt(const __half h) { + return __hip_hc_ir_hrsqrt_half(h); +} + +__device__ static inline __half hsin(const __half h) { + return __hip_hc_ir_hsin_half(h); +} + +__device__ static inline __half hsqrt(const __half a) { + return __hip_hc_ir_hsqrt_half(a); +} + +__device__ static inline __half htrunc(const __half a) { + return __hip_hc_ir_htrunc_half(a); +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 05900259f1..55fb48cb91 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -60,6 +60,21 @@ __global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In Out[7] = __hsub(In1[7], In2[7]); Out[8] = __hsub_sat(In1[8], In2[8]); Out[9] = hdiv(In1[9], In2[9]); + Out[10] = hceil(In1[10]); + Out[11] = hcos(In1[11]); + Out[12] = hexp(In1[12]); + Out[13] = hexp10(In1[13]); + Out[14] = hexp2(In1[14]); + Out[15] = hfloor(In1[15]); + Out[16] = hlog(In1[16]); + Out[17] = hlog10(In1[17]); + Out[18] = hlog2(In1[18]); +// Out[19] = hrcp(In1[19]); + Out[20] = hrint(In1[20]); + Out[21] = hrsqrt(In1[21]); + Out[22] = hsin(In1[22]); + Out[23] = hsqrt(In1[23]); + Out[24] = htrunc(In1[24]); } __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){ From 1f5fe6714b4ba7d292f357573b8ccbb3debe937f Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 12:27:11 -0600 Subject: [PATCH 005/104] added half2 math operations 1. They use SDWA + LLVM IR 2. Added these functions to test 3. Need to do exp, exp10, log, log10, rint Change-Id: I06176acc6cb8bb054495310531777406a41b54e4 [ROCm/hip commit: 0e576295b411a4e0ce0fd29edf5222d41f22a42d] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 76 +++++++++++++++++++ projects/hip/src/hip_ir.ll | 60 +++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 16 ++++ 3 files changed, 152 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 002fbdd3ce..c54aef319b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -69,6 +69,17 @@ extern "C" __half __hip_hc_ir_hsin_half(__half) __asm("llvm.sin.f16"); extern "C" __half __hip_hc_ir_hsqrt_half(__half) __asm("llvm.sqrt.f16"); extern "C" __half __hip_hc_ir_htrunc_half(__half) __asm("llvm.trunc.f16"); +extern "C" int __hip_hc_ir_h2ceil_int(int); +extern "C" int __hip_hc_ir_h2cos_int(int); +extern "C" int __hip_hc_ir_h2exp2_int(int); +extern "C" int __hip_hc_ir_h2floor_int(int); +extern "C" int __hip_hc_ir_h2log2_int(int); +extern "C" int __hip_hc_ir_h2rcp_int(int); +extern "C" int __hip_hc_ir_h2rsqrt_int(int); +extern "C" int __hip_hc_ir_h2sin_int(int); +extern "C" int __hip_hc_ir_h2sqrt_int(int); +extern "C" int __hip_hc_ir_h2trunc_int(int); + __device__ static inline __half __hadd(const __half a, const __half b) { return __hip_hc_ir_hadd_half(a, b); } @@ -682,6 +693,71 @@ __device__ static inline __half htrunc(const __half a) { return __hip_hc_ir_htrunc_half(a); } +/* +Half2 Math Operations +*/ + +__device__ static inline __half2 h2ceil(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2ceil_int(h.q); + return a; +} + +__device__ static inline __half2 h2cos(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2cos_int(h.q); + return a; +} + +__device__ static inline __half2 h2exp2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2exp2_int(h.q); + return a; +} + +__device__ static inline __half2 h2floor(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2floor_int(h.q); + return a; +} + +__device__ static inline __half2 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 diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 52460a38bb..739717c740 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -86,4 +86,64 @@ define i32 @__hip_hc_ir_hsub2_int(i32 %a, i32 %b) #1 { 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/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 55fb48cb91..c194a42ca2 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -88,6 +88,21 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2 Out[7] = __hsub2(In1[7], In2[7]); Out[8] = __hsub2_sat(In1[8], In2[8]); Out[9] = h2div(In1[9], In2[9]); + Out[10] = h2ceil(In1[10]); + Out[11] = h2cos(In1[11]); +// Out[12] = h2exp(In1[12]); +// Out[13] = h2exp10(In1[13]); + Out[14] = h2exp2(In1[14]); + Out[15] = h2floor(In1[15]); +// Out[16] = h2log(In1[16]); +// Out[17] = h2log10(In1[17]); + Out[18] = h2log2(In1[18]); + Out[19] = h2rcp(In1[19]); +// Out[20] = h2rint(In1[20]); + Out[21] = h2rsqrt(In1[21]); + Out[22] = h2sin(In1[22]); + Out[23] = h2sqrt(In1[23]); + Out[24] = h2trunc(In1[24]); } __global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) { @@ -109,6 +124,7 @@ __global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __ha Out[5] = __hle2(In1[5], In2[5]); Out[6] = __hlt2(In1[6], In2[6]); Out[7] = __hne2(In1[7], In2[7]); + } int main(){ From fa376d6d7164d3c763f250bd09a8ab0ee1aaa295 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 13:26:10 -0600 Subject: [PATCH 006/104] added half2 log, log10, exp, exp10 math functions 1. Enabled tests for log, log10, exp, exp10 half2 2. h2rint is still disabled. Change-Id: I01f6002f6992259919893c524c526db5ee09473a [ROCm/hip commit: bf45105c7c2b44e38c57f2185254fd18c23f3e01] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 31 +++++++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 8 ++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index c54aef319b..eb63c7cd60 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -709,6 +709,22 @@ __device__ static inline __half2 h2cos(const __half2 h) { return a; } +__device__ static inline __half2 h2exp(const __half2 h) { + __half2 factor; + factor.p[0] = 1.442694; + factor.p[1] = 1.442694; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + +__device__ static inline __half2 h2exp10(const __half2 h) { + __half2 factor; + factor.p[0] = 3.3219281; + factor.p[1] = 3.3219281; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + __device__ static inline __half2 h2exp2(const __half2 h) { __half2 a; a.q = __hip_hc_ir_h2exp2_int(h.q); @@ -721,6 +737,21 @@ __device__ static inline __half2 h2floor(const __half2 h) { 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); diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index c194a42ca2..975a494b2a 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -90,12 +90,12 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2 Out[9] = h2div(In1[9], In2[9]); Out[10] = h2ceil(In1[10]); Out[11] = h2cos(In1[11]); -// Out[12] = h2exp(In1[12]); -// Out[13] = h2exp10(In1[13]); + Out[12] = h2exp(In1[12]); + Out[13] = h2exp10(In1[13]); Out[14] = h2exp2(In1[14]); Out[15] = h2floor(In1[15]); -// Out[16] = h2log(In1[16]); -// Out[17] = h2log10(In1[17]); + Out[16] = h2log(In1[16]); + Out[17] = h2log10(In1[17]); Out[18] = h2log2(In1[18]); Out[19] = h2rcp(In1[19]); // Out[20] = h2rint(In1[20]); From 8e411f0beb632cb644c6584ce2084b99da44d021 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 12:10:05 -0600 Subject: [PATCH 007/104] Added type conversion intrinsics 1. Added all type conversion intrinsics 2. NO TESTS have been added. (Will add in next commit) 3. Sanatized code in hip_runtime.h 4. Added passed() to hipTestHalf to make it pass on HIT Change-Id: I0987963c802fc7ff4d7e07d7b88d86da35da53c9 [ROCm/hip commit: 6f2cfddc670835a3965afe252352c488680b846d] --- .../include/hip/hcc_detail/device_functions.h | 112 +++++- .../hip/include/hip/hcc_detail/hip_fp16.h | 4 + .../hip/include/hip/hcc_detail/hip_runtime.h | 30 +- projects/hip/src/device_functions.cpp | 362 ++++++++++++++++-- projects/hip/src/device_util.cpp | 10 - .../hip/tests/src/deviceLib/hipTestHalf.cpp | 2 +- 6 files changed, 462 insertions(+), 58 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index e2b061c640..e6771650a2 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,15 +23,119 @@ THE SOFTWARE. #include #include -__device__ float __int_as_float (int x); +/* +Rounding modes are not yet supported in HIP +*/ -__device__ double __hiloint2double (int hi, int lo); +__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 __double2loint(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__ 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/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index eb63c7cd60..8ae6d0d85b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -325,6 +325,10 @@ __device__ static inline __half __float2half_rd(const float a) { return (__half)a; } +__device__ static inline __half __float2half_rn(const float a) { + return (__half)a; +} + __device__ static inline __half __float2half_ru(const float a) { return (__half)a; } diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f747b446d7..f595ff1c05 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -136,12 +136,10 @@ __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); @@ -174,34 +172,24 @@ __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); @@ -214,8 +202,22 @@ __device__ float ynf(int n, float x); __host__ __device__ float cospif(float x); __host__ __device__ float sinpif(float x); -__device__ float sqrtf(float x); +// /__device__ float sqrtf(float x); __host__ __device__ float rsqrtf(float x); +__host__ float normcdff(float y); + +__host__ float erfcinvf(float y); +__host__ float erfcxf(float x); +__host__ float erfinvf(float y); +__host__ float norm3df(float a, float b, float c); +__host__ float normcdfinvf(float y); +__host__ float norm4df(float a, float b, float c, float d); +__host__ float rcbrtf(float x); +__host__ float rhypotf(float x, float y); +__host__ float rnorm3df(float a, float b, float c); +__host__ float rnormf(int dim, const float* a); +__host__ float rnorm4df(float a, float b, float c, float d); +__host__ void sincospif(float x, float *sptr, float *cptr); __device__ double acos(double x); __device__ double acosh(double x); diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 0de0cf7f6b..01d18d8d28 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -19,38 +19,342 @@ THE SOFTWARE. #include -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; } diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index db0f494af4..cf5d6ff5af 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -2179,16 +2179,6 @@ __device__ double __hip_fast_dsqrt_rz(double x) { return hc::fast_math::sqrt(x); } -__device__ double __longlong_as_double(long long int x) -{ - return static_cast(x); -} - -__device__ long long __double_as_longlong(double x) -{ - return static_cast(x); -} - __device__ void __threadfence_system(void){ // no-op } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 975a494b2a..12b7e2e270 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -128,5 +128,5 @@ __global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __ha } int main(){ - + passed(); } From 38edad98a68af66250e41c7c988301d81e3497ee Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 12:32:35 -0600 Subject: [PATCH 008/104] moved most of the fp16 code inside hip_fp16.cpp 1. As we use holder data structure, we move all the cmp, math, cvt apis to cpp file 2. All the tests passed 3. Add more extensive testing for half Change-Id: I92c6399dace602a0a24432728e3f2a07124e6fb1 [ROCm/hip commit: 18631efbc0bf9f23751689dd33359cfc4c112344] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 565 ++++-------------- projects/hip/src/hip_fp16.cpp | 468 +++++++++++++++ 2 files changed, 572 insertions(+), 461 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 8ae6d0d85b..755cb19f6d 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,17 +36,6 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; -struct hipHalfHolder{ - union { - __half h; - unsigned short s; - }; -}; - -#define HINF 65504 - -static struct hipHalfHolder __hInfValue = {HINF}; - 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); @@ -186,456 +175,6 @@ __device__ static inline __half2 h2div(__half2 a, __half2 b) { return c; } -/* -Half comparision Functions -*/ - -__device__ static inline bool __heq(__half a, __half b) { - return a == b ? true : false; -} - -__device__ static inline bool __hge(__half a, __half b) { - return a >= b ? true : false; -} - -__device__ static inline bool __hgt(__half a, __half b) { - return a > b ? true : false; -} - -__device__ static inline bool __hisinf(__half a) { - return a == __hInfValue.h ? true : false; -} - -__device__ static inline bool __hisnan(__half a) { - return a > __hInfValue.h ? 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; -} - -/* -Half2 Comparision Functions -*/ - -__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 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 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 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 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 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 __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __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__ static inline __half2 __float22half2_rn(const float2 a) { - __half2 b; - b.p[0] = (__half)a.x; - b.p[1] = (__half)a.y; - return b; -} - -__device__ static inline __half __float2half(const float a) { - return (__half)a; -} - -__device__ static inline __half2 __float2half2_rn(const float a) { - __half2 b; - b.p[0] = (__half)a; - b.p[1] = (__half)a; - return b; -} - -__device__ static inline __half __float2half_rd(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_rn(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_ru(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_rz(const float a) { - return (__half)a; -} - -__device__ static inline __half2 __floats2half2_rn(const float a, const float b) { - __half2 c; - c.p[0] = (__half)a; - c.p[1] = (__half)b; - return c; -} - -__device__ static inline float2 __half22float2(const __half2 a) { - float2 b; - b.x = (float)a.p[0]; - b.y = (float)a.p[1]; - return b; -} - -__device__ static inline float __half2float(const __half a) { - return (float)a; -} - -__device__ static inline __half2 half2half2(const __half a) { - __half2 b; - b.p[0] = a; - b.p[1] = a; - return b; -} - -__device__ static inline int __half2int_rd(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_rn(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_ru(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_rz(__half h) { - return (int)h; -} - -__device__ static inline long long int __half2ll_rd(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_rn(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_ru(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_rz(__half h) { - return (long long int)h; -} - -__device__ static inline short __half2short_rd(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_rn(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_ru(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_rz(__half h) { - return (short)h; -} - -__device__ static inline unsigned int __half2uint_rd(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_rn(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_ru(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_rz(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned long long int __half2ull_rd(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_rn(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_ru(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_rz(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned short int __half2ushort_rd(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_rn(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_ru(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_rz(__half h) { - return (unsigned short int)h; -} - -__device__ static inline short int __half_as_short(const __half h) { - hipHalfHolder hH; - hH.h = h; - return (short)hH.s; -} - -__device__ static inline unsigned short int __half_as_ushort(const __half h) { - hipHalfHolder hH; - hH.h = h; - return hH.s; -} - -__device__ static inline __half2 __halves2half2(const __half a, const __half b) { - __half2 c; - c.p[0] = a; - c.p[1] = b; - return c; -} - -__device__ static inline float __high2float(const __half2 a) { - return (float)a.p[1]; -} - -__device__ static inline __half __high2half(const __half2 a) { - return a.p[1]; -} - -__device__ static inline __half2 __high2half2(const __half2 a) { - __half2 b; - b.p[0] = a.p[1]; - b.p[1] = a.p[1]; - return b; -} - -__device__ static inline __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__ static inline __half __int2half_rd(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_rn(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_ru(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_rz(int i) { - return (__half)i; -} - -__device__ static inline __half __ll2half_rd(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_rn(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_ru(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_rz(long long int i){ - return (__half)i; -} - -__device__ static inline float __low2float(const __half2 a) { - return (float)a.p[0]; -} - -__device__ static inline __half __low2half(const __half2 a) { - return a.p[0]; -} - -__device__ static inline __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__ static inline __half2 __low2half2(const __half2 a) { - __half2 b; - b.p[0] = a.p[0]; - b.p[1] = a.p[0]; - return b; -} - -__device__ static inline __half2 __lowhigh2highlow(const __half2 a) { - __half2 b; - b.p[0] = a.p[1]; - b.p[1] = a.p[0]; - return b; -} - -__device__ static inline __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__ static inline __half __short2half_rd(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_rn(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_ru(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_rz(short int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rd(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rn(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_ru(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rz(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rd(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rn(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_ru(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rz(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rd(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rn(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_ru(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rz(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort_as_half(const unsigned short int i) { - hipHalfHolder hH; - hH.s = i; - return hH.h; -} __device__ static inline __half hceil(const __half h) { return __hip_hc_ir_hceil_half(h); @@ -792,6 +331,110 @@ __device__ static inline __half2 h2trunc(const __half2 h) { return a; } +__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); + +/* +Conversion instructions +*/ +__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); + #endif diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 83e0a161c7..ac79ddba08 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,6 +22,472 @@ THE SOFTWARE. #include"hip/hip_fp16.h" +struct hipHalfHolder{ + union { + __half h; + unsigned short s; + }; +}; + +#define HINF 65504 + +static struct hipHalfHolder __hInfValue = {HINF}; +/* +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 +841,6 @@ __device__ __half2 __soft_low2half2(const __half2 a, const __half2 b){ return {a.p[0], b.p[0]}; } + + #endif From 72202cccbd5262dc29ee7e6b384824ae4d5cd1c6 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 14:55:29 -0600 Subject: [PATCH 009/104] v1: Working on Integer Intrinsics 1. Half way through 2. May not work 3. No test written Change-Id: I705b743a78b142ff068e2521870e73fca7ad2b1c [ROCm/hip commit: b09ad764a1d37595aafa8fbbee0765bc797d454a] --- .../include/hip/hcc_detail/device_functions.h | 53 ++++++ .../hip/include/hip/hcc_detail/hip_runtime.h | 24 --- projects/hip/src/device_functions.cpp | 164 ++++++++++++++++++ projects/hip/src/device_util.cpp | 110 ------------ projects/hip/src/hip_ir.ll | 25 +++ 5 files changed, 242 insertions(+), 134 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index e6771650a2..8eb9d6a46c 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,59 @@ THE SOFTWARE. #include #include +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); +// 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 inline unsigned int __hadd(int x, int y) +{ + return (x + y) >> 1; +} +__device__ static inline int __mul24(int x, int y) +{ + return __hip_hc_ir_mul24_int(x, y); +} +__device__ long long int __mul64hi(long long int x, long long int y); +__device__ int __mulhi(int x, int y) +{ + return __hip_hc_ir_mulhi_int(x, y); +} +__device__ unsigned int __popc( unsigned int x); +__device__ unsigned int __popcll( unsigned long long int x); +__device__ int __rhadd(int x, int y) +{ + return (x + y + 1) >> 1; +} +//__device__ unsigned int __sad(int x, int y, int z); +/* +Implemented signed version of sad +*/ +__device__ 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__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); +__device__ unsigned int __umulhi(unsigned int x, unsigned int y); +__device__ unsigned int __urhadd(unsigned int x, unsigned int y); +__device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + +// warp vote function __all __any __ballot +__device__ int __all( int input); +__device__ int __any( int input); +__device__ unsigned long long int __ballot( int input); + /* Rounding modes are not yet supported in HIP */ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f595ff1c05..f6967c3445 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -420,30 +420,6 @@ __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 -__device__ int __all( int input); -__device__ int __any( int input); -__device__ unsigned long long int __ballot( int input); - // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 01d18d8d28..7fb67b787a 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -18,6 +18,10 @@ THE SOFTWARE. */ #include +#include +#include +#include +#include "device_util.h" struct holder64Bit{ union{ @@ -358,3 +362,163 @@ __device__ float __ull2float_rz(unsigned long long int x) { return (float)x; } + + + +// 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))); + +struct uchar2Holder cHoldVal; +struct ucharHolder cHoldKey; +struct ucharHolder cHoldOut; + +struct intHolder iHold1; +struct intHolder iHold2; +struct uintHolder uHold1; +struct uintHolder uHold2; + +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s) +{ + 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) +{ + 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) +{ + uHold1.ul = x; + uHold2.ul = y; + uHold1.ul = uHold1.ui[1] * uHold2.ui[1]; + return uHold1.ul; +} diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index cf5d6ff5af..e875db1cf9 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -1843,117 +1843,7 @@ __device__ unsigned int atomicDec(unsigned int* address, return hc::__atomic_wrapdec(address,val); } -//__mul24 __umul24 -__device__ int __mul24(int arg1, - int arg2) -{ - return hc::__mul24(arg1, arg2); -} -__device__ unsigned int __umul24(unsigned int arg1, - unsigned int arg2) -{ - return hc::__mul24(arg1, arg2); -} -__device__ unsigned int test__popc(unsigned int input) -{ - return hc::__popcount_u32_b32(input); -} - -// integer intrinsic function __poc __clz __ffs __brev -__device__ unsigned int __popc( unsigned int input) -{ - return hc::__popcount_u32_b32(input); -} - -__device__ unsigned int test__popc(unsigned int 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); -} // warp vote function __all __any __ballot __device__ int __all( int input) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 739717c740..a20b57016e 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -146,4 +146,29 @@ define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { ret i32 %1 } +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 } From b2ec4294321da0ef5d26c38976474dfc9c9ee30a Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:00:09 -0600 Subject: [PATCH 010/104] fixed broken tests and device code for integer intrinsics 1. Fixed build issues with new Integer intrinsics 2. Changed tests to work exactly as CUDA code 3. Still some integer intrinsics need to be supported Change-Id: Ie6f4171259cf4da517436895d4f6f01e01f59b11 [ROCm/hip commit: c0fd0921cbb1c25553c258ea65d44c2f7721b4cb] --- .../include/hip/hcc_detail/device_functions.h | 13 ++++--------- .../hip/include/hip/hcc_detail/hip_runtime.h | 5 +++++ .../tests/src/deviceLib/hipIntegerIntrinsics.cpp | 1 + projects/hip/tests/src/deviceLib/hip_ballot.cpp | 16 +++++++++------- projects/hip/tests/src/deviceLib/hip_brev.cpp | 3 +-- projects/hip/tests/src/deviceLib/hip_clz.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_ffs.cpp | 3 +-- projects/hip/tests/src/deviceLib/hip_popc.cpp | 3 +-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 8eb9d6a46c..bed206c0ed 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -44,21 +44,21 @@ __device__ static inline int __mul24(int x, int y) return __hip_hc_ir_mul24_int(x, y); } __device__ long long int __mul64hi(long long int x, long long int y); -__device__ int __mulhi(int x, int y) +__device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); -__device__ int __rhadd(int x, int y) +__device__ static inline int __rhadd(int x, int y) { return (x + y + 1) >> 1; } //__device__ unsigned int __sad(int x, int y, int z); /* -Implemented signed version of sad +Implement signed version of sad */ -__device__ unsigned int __uhadd(unsigned int x, unsigned int y) +__device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { return (x + y) >> 1; } @@ -71,11 +71,6 @@ __device__ unsigned int __umulhi(unsigned int x, unsigned int y); __device__ unsigned int __urhadd(unsigned int x, unsigned int y); __device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); -// warp vote function __all __any __ballot -__device__ int __all( int input); -__device__ int __any( int input); -__device__ unsigned long long int __ballot( int input); - /* Rounding modes are not yet supported in HIP */ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f6967c3445..e911d17ebb 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -420,6 +420,11 @@ __device__ unsigned int atomicInc(unsigned int* address, __device__ unsigned int atomicDec(unsigned int* address, unsigned int val); + // warp vote function __all __any __ballot +__device__ int __all( int input); +__device__ int __any( int input); +__device__ unsigned long long int __ballot( int input); + // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index abe0b66e90..f9328e7a2c 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "hip/hip_runtime.h" +#include "hip/device_functions.h" #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hip_ballot.cpp b/projects/hip/tests/src/deviceLib/hip_ballot.cpp index 236ceb57fe..629e676bc7 100644 --- a/projects/hip/tests/src/deviceLib/hip_ballot.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ballot.cpp @@ -26,9 +26,11 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" +#include "hip/device_functions.h" + #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 "hip/device_functions.h" #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..869f4406f5 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 "hip/device_functions.h" #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..ba9bd7b9a0 100644 --- a/projects/hip/tests/src/deviceLib/hip_ffs.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ffs.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" - +#include "hip/device_functions.h" #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..6fe214c7fa 100644 --- a/projects/hip/tests/src/deviceLib/hip_popc.cpp +++ b/projects/hip/tests/src/deviceLib/hip_popc.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" - +#include "hip/device_functions.h" #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -172,4 +172,3 @@ int main() { return errors; } - From 675ecdd54c3156d3562587c0b7bf06d194cc029e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:27:51 -0600 Subject: [PATCH 011/104] added last few integer intrinsic support 1. Added usad, umulhi, urhadd 2. Corrected implementation of __hadd, __hradd 3. TODO: __sad(). It gets tricky as ISA sees them as unsigned Change-Id: Ibd2c2133b462f9393f3990355706386c79256bba [ROCm/hip commit: 02c7f3a70fff8df3bf482e014ad74ea2279cd7a2] --- .../include/hip/hcc_detail/device_functions.h | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index bed206c0ed..fb5a1a6c18 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -27,6 +27,7 @@ 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); @@ -37,7 +38,10 @@ __device__ unsigned int __ffs(int x); __device__ unsigned int __ffsll(long long int x); __device__ static inline unsigned int __hadd(int x, int y) { - return (x + y) >> 1; + 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) { @@ -52,7 +56,10 @@ __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); __device__ static inline int __rhadd(int x, int y) { - return (x + y + 1) >> 1; + int z = x + y + 1; + int sign = z & 0x8000000; + int value = z & 0x7FFFFFFF; + return ((value) >> 1 || sign); } //__device__ unsigned int __sad(int x, int y, int z); /* @@ -67,9 +74,18 @@ __device__ static inline int __umul24(unsigned int x, unsigned int y) return __hip_hc_ir_umul24_int(x, y); } __device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); -__device__ unsigned int __umulhi(unsigned int x, unsigned int y); -__device__ unsigned int __urhadd(unsigned int x, unsigned int y); -__device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); +__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 From ea01905ceec821ce5eec4706fd7617d667798121 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:59:08 -0600 Subject: [PATCH 012/104] enabled integer intrinsics tests Change-Id: I5d28d556f228240eda2fc0098121ed3b29b041e7 [ROCm/hip commit: 13ce9ece77f6109efc09dd7fdc1ba9181dc56894] --- .../include/hip/hcc_detail/device_functions.h | 12 ++++++---- projects/hip/src/device_functions.cpp | 19 ++++++++------- .../src/deviceLib/hipIntegerIntrinsics.cpp | 24 +++++++++---------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index fb5a1a6c18..06beeb23f8 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 @@ -28,6 +28,7 @@ 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); @@ -61,10 +62,11 @@ __device__ static inline int __rhadd(int x, int y) int value = z & 0x7FFFFFFF; return ((value) >> 1 || sign); } -//__device__ unsigned int __sad(int x, int y, int z); -/* -Implement signed version of sad -*/ +__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; diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 7fb67b787a..4b0eb9a5ff 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -363,7 +363,9 @@ __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) @@ -486,17 +488,12 @@ struct uintHolder { }; }__attribute__((aligned(8))); -struct uchar2Holder cHoldVal; -struct ucharHolder cHoldKey; -struct ucharHolder cHoldOut; - -struct intHolder iHold1; -struct intHolder iHold2; -struct uintHolder uHold1; -struct uintHolder uHold2; __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; @@ -509,6 +506,8 @@ __device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int __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]; @@ -517,6 +516,8 @@ __device__ long long __mul64hi(long long int x, long long int y) __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]; diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index f9328e7a2c..63530574d8 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 @@ -30,27 +30,27 @@ __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) From 77401c9b642d7d628210586f1c2beca9458f1224 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 14:57:51 -0600 Subject: [PATCH 013/104] Moved device code to mimic cuda header behavior 1. All fp32, fp64 math device/host functions should be in math_functions.h/.cpp 2. All fp32, fp64 fast math intrinsics for device/host functions should be in device_functions.h/.cpp 3. All the device code implementations should be in device_util.h/.cpp 4. Hence, made changes appropriately by moving code and creating new header files 5. Added math_functions.cpp/.h 6. Changed #ifndef signature to make sure no conflicts between headers with same names in hip/hip_runtime.h and hip/hcc_detail/hip_runtime.h 7. Changed tests to fit the code changes, making them to include appropriate headers 8. Added math_functions.cpp to CMakeLists.txt 9. Some of the tests are still broken, mostly host math functions will fix them in next commit 10. TODO: FIX compilation issues for host math functions Change-Id: I7a17637d7e294a7d224ffba932c1a08668febd26 [ROCm/hip commit: b723169ee9517cf36ae1ca38dec821233a37767e] --- projects/hip/CMakeLists.txt | 3 +- .../include/hip/hcc_detail/device_functions.h | 167 +++ .../hip/include/hip/hcc_detail/hip_fp16.h | 8 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 448 -------- .../include/hip/hcc_detail/math_functions.h | 288 +++++ projects/hip/include/hip/math_functions.h | 49 + projects/hip/src/device_functions.cpp | 68 ++ projects/hip/src/device_util.cpp | 1008 +---------------- projects/hip/src/device_util.h | 117 ++ projects/hip/src/math_functions.cpp | 971 ++++++++++++++++ .../hipDoublePrecisionIntrinsics.cpp | 35 +- .../hipDoublePrecisionMathDevice.cpp | 21 +- .../deviceLib/hipDoublePrecisionMathHost.cpp | 5 +- .../hip/tests/src/deviceLib/hipFloatMath.cpp | 1 + .../src/deviceLib/hipFloatMathPrecise.cpp | 3 +- .../src/deviceLib/hipIntegerIntrinsics.cpp | 4 +- .../hipSinglePrecisionIntrinsics.cpp | 59 +- .../hipSinglePrecisionMathDevice.cpp | 3 +- .../deviceLib/hipSinglePrecisionMathHost.cpp | 3 +- .../hip/tests/src/deviceLib/hipTestDevice.cpp | 5 +- .../src/deviceLib/hipTestDeviceDouble.cpp | 5 +- .../hip/tests/src/deviceLib/hip_anyall.cpp | 3 +- .../hip/tests/src/deviceLib/hip_ballot.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_brev.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_clz.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_ffs.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_popc.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_trig.cpp | 3 +- .../runtimeApi/stream/hipAPIStreamDisable.cpp | 3 +- .../runtimeApi/stream/hipAPIStreamEnable.cpp | 3 +- 30 files changed, 1759 insertions(+), 1540 deletions(-) create mode 100644 projects/hip/include/hip/hcc_detail/math_functions.h create mode 100644 projects/hip/include/hip/math_functions.h create mode 100644 projects/hip/src/math_functions.cpp diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 1168b65be2..cbd2050025 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -181,7 +181,8 @@ if(HIP_PLATFORM STREQUAL "hcc") 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") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 06beeb23f8..0489a72c8b 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,173 @@ THE SOFTWARE. #include #include +// 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__ 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); +} + + 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); diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 755cb19f6d..73049eb5fb 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" @@ -452,8 +452,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 e911d17ebb..f11846a0da 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -121,208 +121,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); - -__device__ float erfcxf(float x); -__device__ float erff(float x); -__device__ 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); -__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 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); -__host__ __device__ unsigned signbit(float a); -__device__ 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); -__host__ float normcdff(float y); - -__host__ float erfcinvf(float y); -__host__ float erfcxf(float x); -__host__ float erfinvf(float y); -__host__ float norm3df(float a, float b, float c); -__host__ float normcdfinvf(float y); -__host__ float norm4df(float a, float b, float c, float d); -__host__ float rcbrtf(float x); -__host__ float rhypotf(float x, float y); -__host__ float rnorm3df(float a, float b, float c); -__host__ float rnormf(int dim, const float* a); -__host__ float rnorm4df(float a, float b, float c, float d); -__host__ void sincospif(float x, float *sptr, float *cptr); - -__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; @@ -451,252 +249,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 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..5a0e21f83c --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -0,0 +1,288 @@ +/* +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 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); + +__device__ float erfcxf(float x); +__device__ float erff(float x); +__device__ 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__ 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 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 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); +__host__ __device__ unsigned signbit(float a); +__device__ 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); +__host__ float normcdff(float y); + +__host__ float erfcinvf(float y); +__host__ float erfcxf(float x); +__host__ float erfinvf(float y); +__host__ float norm3df(float a, float b, float c); +__host__ float normcdfinvf(float y); +__host__ float norm4df(float a, float b, float c, float d); +__host__ float rcbrtf(float x); +__host__ float rhypotf(float x, float y); +__host__ float rnorm3df(float a, float b, float c); +__host__ float rnormf(int dim, const float* a); +__host__ float rnorm4df(float a, float b, float c, float d); +__host__ void sincospif(float x, float *sptr, float *cptr); + +__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 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); +__host__ double norm(double x, const double *t); + +#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/math_functions.h b/projects/hip/include/hip/math_functions.h new file mode 100644 index 0000000000..d33f7a2e90 --- /dev/null +++ b/projects/hip/include/hip/math_functions.h @@ -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. +*/ + +//! HIP = Heterogeneous-compute Interface for Portability +//! +//! Define a extremely thin runtime layer that allows source code to be compiled unmodified +//! through either AMD HCC or NVCC. Key features tend to be in the spirit +//! and terminology of CUDA, but with a portable path to other accelerators as well: +// +//! Both paths support rich C++ features including classes, templates, lambdas, etc. +//! Runtime API is C +//! Memory management is based on pure pointers and resembles malloc/free/copy. +// +//! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. +//! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. + +#pragma once + +// 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/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 4b0eb9a5ff..abc9db570e 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -523,3 +523,71 @@ __device__ unsigned long long __umul64hi(unsigned long long int x, unsigned long 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 e875db1cf9..d80d9e7ef5 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,69 +96,7 @@ __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) @@ -192,39 +130,6 @@ __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 +847,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 + /* Heap size computation for malloc and free device functions. */ @@ -35,4 +37,119 @@ THE SOFTWARE. #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/math_functions.cpp b/projects/hip/src/math_functions.cpp new file mode 100644 index 0000000000..34a80448db --- /dev/null +++ b/projects/hip/src/math_functions.cpp @@ -0,0 +1,971 @@ + +/* +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__ 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 +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -27,18 +28,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 +48,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); diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp index 996577e840..537fcbbba8 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -43,8 +44,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 +62,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 +72,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 +82,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); diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 9980dad277..eff39102c6 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -85,7 +86,7 @@ __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); 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..12f7875949 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" __global__ void FloatMathPrecise(hipLaunchParm lp) diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index 63530574d8..d712c5a93b 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -19,8 +19,8 @@ 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 "hip/device_functions.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp index caddcc0149..6737c6ee9d 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -30,44 +31,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); } diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp index a8c1194aab..4576faed93 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 36aa852d81..d48cea5ff6 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -19,7 +19,8 @@ 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 #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp index 9d90eb7de0..2c7488671b 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) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp index c401a44cbd..f4e8ee20b8 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) 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 629e676bc7..742c47a065 100644 --- a/projects/hip/tests/src/deviceLib/hip_ballot.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ballot.cpp @@ -25,8 +25,8 @@ THE SOFTWARE. #include -#include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_brev.cpp b/projects/hip/tests/src/deviceLib/hip_brev.cpp index d9228fe23c..855a8bec47 100644 --- a/projects/hip/tests/src/deviceLib/hip_brev.cpp +++ b/projects/hip/tests/src/deviceLib/hip_brev.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_clz.cpp b/projects/hip/tests/src/deviceLib/hip_clz.cpp index 869f4406f5..bdb31f3e8d 100644 --- a/projects/hip/tests/src/deviceLib/hip_clz.cpp +++ b/projects/hip/tests/src/deviceLib/hip_clz.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) #define WIDTH 8 diff --git a/projects/hip/tests/src/deviceLib/hip_ffs.cpp b/projects/hip/tests/src/deviceLib/hip_ffs.cpp index ba9bd7b9a0..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 "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_popc.cpp b/projects/hip/tests/src/deviceLib/hip_popc.cpp index 6fe214c7fa..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 "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) 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/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 Date: Wed, 18 Jan 2017 11:53:47 -0600 Subject: [PATCH 014/104] fixed compilation issues 1. Fixed compilation issues for tests 2. Added missing intrinsics + math functions 3. Disabled some device functions as they are causing linking error with HCC Change-Id: I79d52c4c7a539cc8ef40580247ad97ffcb975f09 [ROCm/hip commit: ea382e15f841ba0e06583de4262ca1159b498a1b] --- .../include/hip/hcc_detail/device_functions.h | 255 ++++++++++++++---- .../include/hip/hcc_detail/math_functions.h | 76 +++--- projects/hip/src/math_functions.cpp | 67 ++++- .../hipDoublePrecisionMathDevice.cpp | 12 +- .../deviceLib/hipDoublePrecisionMathHost.cpp | 6 +- 5 files changed, 299 insertions(+), 117 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 0489a72c8b..a2894f3d9b 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -61,6 +61,90 @@ __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); } @@ -81,6 +165,23 @@ __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); } @@ -97,6 +198,12 @@ __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); } @@ -109,68 +216,57 @@ __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); + +/* +Double Precision Intrinsics +*/ + +__device__ static inline double __dadd_rd(double x, double y) { + return x + y; } -__device__ inline float __fmaf_rn(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_rn(double x, double y) { + return x + y; } -__device__ inline float __fmaf_ru(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_ru(double x, double y) { + return x + y; } -__device__ inline float __fmaf_rz(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_rz(double x, double y) { + return x + y; } -__device__ inline float __frcp_rd(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rd(double x, double y) { + return x / y; } -__device__ inline float __frcp_rn(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rn(double x, double y) { + return x / y; } -__device__ inline float __frcp_ru(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_ru(double x, double y) { + return x / y; } -__device__ inline float __frcp_rz(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rz(double x, double y) { + return x / y; } -__device__ inline double __dsqrt_rd(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_rd(double x, double y) { + return x * y; } -__device__ inline double __dsqrt_rn(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_rn(double x, double y) { + return x * y; } -__device__ inline double __dsqrt_ru(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_ru(double x, double y) { + return x * y; } -__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__ static inline double __dmul_rz(double x, double y) { + return x * y; } __device__ inline double __drcp_rd(double x) { @@ -190,6 +286,55 @@ __device__ inline double __drcp_rz(double 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); @@ -204,51 +349,42 @@ __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 inline unsigned int __hadd(int x, int y) -{ +__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) -{ +__device__ static inline int __mul24(int x, int y) { return __hip_hc_ir_mul24_int(x, y); } __device__ long long int __mul64hi(long long int x, long long int y); -__device__ static inline int __mulhi(int x, int y) -{ +__device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); -__device__ static inline int __rhadd(int x, int 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) -{ +__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) -{ +__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) -{ +__device__ static inline int __umul24(unsigned int x, unsigned int y) { return __hip_hc_ir_umul24_int(x, y); } __device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); -__device__ static inline unsigned int __umulhi(unsigned int x, unsigned int 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) -{ +__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) @@ -266,7 +402,6 @@ __device__ float __double2float_ru(double x); __device__ float __double2float_rz(double x); __device__ int __double2hiint(double x); -__device__ int __double2loint(double x); __device__ int __double2int_rd(double x); __device__ int __double2int_rn(double x); @@ -278,6 +413,8 @@ __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); diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 5a0e21f83c..21ec4510c6 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -34,16 +34,19 @@ __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 cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); +__device__ __host__ 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); @@ -53,32 +56,34 @@ __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 frexpf(float x, int* nptr); __device__ float hypotf(float x, float y); __device__ float ilogbf(float x); -__host__ __device__ int isfinite(float a); +__device__ __host__ 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__ 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 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 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); @@ -88,14 +93,17 @@ __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__ __host__ 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__ __host__ unsigned 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__ __host__ 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); @@ -103,12 +111,8 @@ __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); -__host__ float normcdff(float y); +__host__ float normcdff(float y); __host__ float erfcinvf(float y); __host__ float erfcxf(float x); __host__ float erfinvf(float y); @@ -122,6 +126,8 @@ __host__ float rnormf(int dim, const float* a); __host__ float rnorm4df(float a, float b, float c, float d); __host__ void sincospif(float x, float *sptr, float *cptr); + + __device__ double acos(double x); __device__ double acosh(double x); __device__ double asin(double x); @@ -134,7 +140,7 @@ __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__ __host__ double cospi(double x); __device__ double cyl_bessel_i0(double x); __device__ double cyl_bessel_i1(double x); __device__ double erf(double x); @@ -153,10 +159,10 @@ __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 frexp(double x, int *nptr); __device__ double hypot(double x, double y); __device__ double ilogb(double x); -__host__ __device__ unsigned isfinite(double x); +__device__ __host__ unsigned isfinite(double x); __device__ unsigned isinf(double x); __device__ unsigned isnan(double x); __device__ double j0(double x); @@ -173,44 +179,34 @@ __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 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 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__ __host__ 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__ __host__ 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__ __host__ double sinpi(double x); __device__ double sqrt(double x); __device__ double tan(double x); __device__ double tanh(double x); @@ -224,7 +220,17 @@ __host__ double erfcinv(double y); __host__ double erfcx(double x); __host__ double erfinv(double y); __host__ double fdivide(double x, double y); -__host__ double norm(double x, const double *t); +__host__ double norm(int dim, const double *t); +__host__ double norm3d(double a, double b, double c); +__host__ double norm4d(double a, double b, double c, double d); +__host__ double normcdf(double y); +__host__ double normcdfinv(double y); +__host__ double rcbrt(double x); +__host__ double rhypot(double x, double y); +__host__ double rnorm(int dim, const double* t); +__host__ double rnorm3d(double a, double b, double c); +__host__ double rnorm4d(double a, double b, double c, double d); +__host__ void sincospi(double x, double *sptr, double *cptr); #ifdef HIP_FAST_MATH // Single Precision Precise Math when enabled diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 34a80448db..130d4152ae 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -186,9 +186,10 @@ __device__ float ldexpf(float x, int exp) { return hc::precise_math::ldexpf(x, exp); } -__device__ float lgammaf(float x, int *sign) +__device__ float lgammaf(float x) { - return hc::precise_math::lgammaf(x, sign); + int sign; + return hc::precise_math::lgammaf(x, &sign); } __device__ long long int llrintf(float x) { @@ -566,9 +567,10 @@ __device__ double ldexp(double x, int exp) { return hc::precise_math::ldexp(x, exp); } -__device__ double lgamma(double x, int *sign) +__device__ double lgamma(double x) { - return hc::precise_math::lgamma(x, sign); + int sign; + return hc::precise_math::lgamma(x, &sign); } __device__ long long int llrint(double x) { @@ -626,6 +628,14 @@ __device__ double nextafter(double x, double y) { return hc::precise_math::nextafter(x, y); } +__device__ double norm(int x, const double *d) +{ + double val = 0; + for(int i=0;i Date: Wed, 18 Jan 2017 14:40:50 -0600 Subject: [PATCH 015/104] Added script for generating math api docs 1. Commented out unsupported device math functions 2. Moved function signatures to the top of implementation snippets 3. Added script to generate markdown documentation for device math apis 4. Added the generated file from the script which should be present everytime Change-Id: Ic579dd8b8fdffa6e1b4d4f5f3fd8a803f4dcaac7 [ROCm/hip commit: 91ae5d6bd773ff962228386b6d3c01c76512c692] --- projects/hip/docs/markdown/device_md_gen.py | 508 +++ projects/hip/docs/markdown/hip-math-api.md | 3470 +++++++++++++++++ .../include/hip/hcc_detail/device_functions.h | 108 +- .../include/hip/hcc_detail/math_functions.h | 6 +- 4 files changed, 4081 insertions(+), 11 deletions(-) create mode 100644 projects/hip/docs/markdown/device_md_gen.py create mode 100644 projects/hip/docs/markdown/hip-math-api.md 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..4795ea98e0 --- /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`.\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..daf34fbfa3 --- /dev/null +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -0,0 +1,3470 @@ +# 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`. +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__ __host__ 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__ __host__ 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__ __host__ 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__ __host__ 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__ __host__ unsigned 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__ __host__ 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__ __host__ 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__ __host__ unsigned 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__ __host__ 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__ __host__ unsigned 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__ __host__ 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 + + +### __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 + + +### __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/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index a2894f3d9b..212f22d5dc 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,86 @@ THE SOFTWARE. #include #include + + + + +// Single Precision Fast Math +__device__ float __cosf(float x); +__device__ float __exp10f(float x); +__device__ float __expf(float x); +__device__ static float __fadd_rd(float x, float y); +__device__ static float __fadd_rn(float x, float y); +__device__ static float __fadd_ru(float x, float y); +__device__ static float __fadd_rz(float x, float y); +__device__ static float __fdiv_rd(float x, float y); +__device__ static float __fdiv_rn(float x, float y); +__device__ static float __fdiv_ru(float x, float y); +__device__ static float __fdiv_rz(float x, float y); +__device__ static float __fdividef(float x, float y); +__device__ float __fmaf_rd(float x, float y, float z); +__device__ float __fmaf_rn(float x, float y, float z); +__device__ float __fmaf_ru(float x, float y, float z); +__device__ float __fmaf_rz(float x, float y, float z); +__device__ static float __fmul_rd(float x, float y); +__device__ static float __fmul_rn(float x, float y); +__device__ static float __fmul_ru(float x, float y); +__device__ static float __fmul_rz(float x, float y); +__device__ float __frcp_rd(float x); +__device__ float __frcp_rn(float x); +__device__ float __frcp_ru(float x); +__device__ float __frcp_rz(float x); +__device__ float __frsqrt_rn(float x); +__device__ float __fsqrt_rd(float x); +__device__ float __fsqrt_rn(float x); +__device__ float __fsqrt_ru(float x); +__device__ float __fsqrt_rz(float x); +__device__ static float __fsub_rd(float x, float y); +__device__ static float __fsub_rn(float x, float y); +__device__ static float __fsub_ru(float x, float y); +__device__ float __log10f(float x); +__device__ float __log2f(float x); +__device__ float __logf(float x); +__device__ float __powf(float base, float exponent); +__device__ static float __saturatef(float x); +__device__ void __sincosf(float x, float *s, float *c); +__device__ float __sinf(float x); +__device__ float __tanf(float x); + + +/* +Double Precision Intrinsics +*/ + +__device__ static double __dadd_rd(double x, double y); +__device__ static double __dadd_rn(double x, double y); +__device__ static double __dadd_ru(double x, double y); +__device__ static double __dadd_rz(double x, double y); +__device__ static double __ddiv_rd(double x, double y); +__device__ static double __ddiv_rn(double x, double y); +__device__ static double __ddiv_ru(double x, double y); +__device__ static double __ddiv_rz(double x, double y); +__device__ static double __dmul_rd(double x, double y); +__device__ static double __dmul_rn(double x, double y); +__device__ static double __dmul_ru(double x, double y); +__device__ static double __dmul_rz(double x, double y); +__device__ double __drcp_rd(double x); +__device__ double __drcp_rn(double x); +__device__ double __drcp_ru(double x); +__device__ double __drcp_rz(double x); +__device__ double __dsqrt_rd(double x); +__device__ double __dsqrt_rn(double x); +__device__ double __dsqrt_ru(double x); +__device__ double __dsqrt_rz(double x); +__device__ static double __dsub_rd(double x, double y); +__device__ static double __dsub_rn(double x, double y); +__device__ static double __dsub_ru(double x, double y); +__device__ static double __dsub_rz(double x, double y); +__device__ double __fma_rd(double x, double y, double z); +__device__ double __fma_rn(double x, double y, double z); +__device__ double __fma_ru(double x, double y, double z); +__device__ double __fma_rz(double x, double y, double z); + // Single Precision Fast Math extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); @@ -349,6 +429,21 @@ __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; @@ -358,12 +453,9 @@ __device__ static inline unsigned int __hadd(int x, int y) { __device__ static inline int __mul24(int x, int y) { return __hip_hc_ir_mul24_int(x, y); } -__device__ long long int __mul64hi(long long int x, long long int y); __device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } -__device__ unsigned int __popc( unsigned int x); -__device__ unsigned int __popcll( unsigned long long int x); __device__ static inline int __rhadd(int x, int y) { int z = x + y + 1; int sign = z & 0x8000000; @@ -373,14 +465,12 @@ __device__ static inline int __rhadd(int x, int y) { __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__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); __device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) { return __hip_hc_ir_umulhi_int(x, y); } @@ -440,10 +530,10 @@ 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__ 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); diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 21ec4510c6..b07830958f 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -141,8 +141,8 @@ __device__ double copysign(double x, double y); __device__ double cos(double x); __device__ double cosh(double x); __device__ __host__ double cospi(double x); -__device__ double cyl_bessel_i0(double x); -__device__ double cyl_bessel_i1(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); @@ -232,6 +232,8 @@ __host__ double rnorm3d(double a, double b, double c); __host__ double rnorm4d(double a, double b, double c, double d); __host__ void sincospi(double x, double *sptr, double *cptr); +// ENDPARSER + #ifdef HIP_FAST_MATH // Single Precision Precise Math when enabled From 13c7583874b30a8f5e2998a444b765d0eafe2bad Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 18 Jan 2017 14:49:41 -0600 Subject: [PATCH 016/104] more clarification about using device_md_gen.py Change-Id: I3e207b65683f34d62be3454444ffb32f8814c0aa [ROCm/hip commit: db99ac798b28197c28b5e72f9d346038a3f42570] --- projects/hip/docs/markdown/device_md_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/device_md_gen.py b/projects/hip/docs/markdown/device_md_gen.py index 4795ea98e0..995782189f 100644 --- a/projects/hip/docs/markdown/device_md_gen.py +++ b/projects/hip/docs/markdown/device_md_gen.py @@ -473,7 +473,7 @@ preamble = "# HIP MATH APIs Documentation \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`.\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): From 99fc61be651a5daae5837bfd9b6589a43855ffc5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 18 Jan 2017 15:06:18 -0600 Subject: [PATCH 017/104] moved half device function declarations to top of the file 1. Moved half device functions around so that script can catch the signatures 2. Generated docs for half precision apis Change-Id: Iee27658e3a639fdb02af135e71841dc6427f15e2 [ROCm/hip commit: 56d73aaee78eba849f6e7b9800c2e65901f35f4b] --- projects/hip/docs/markdown/hip-math-api.md | 370 +++++++++++++++++- .../hip/include/hip/hcc_detail/hip_fp16.h | 277 ++++++++----- 2 files changed, 544 insertions(+), 103 deletions(-) diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md index daf34fbfa3..6a8e90eb59 100644 --- a/projects/hip/docs/markdown/hip-math-api.md +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -16,7 +16,7 @@ __device__ static inline float __dotf(float4 x, float4 y) { 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`. +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'` @@ -2716,6 +2716,166 @@ __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); @@ -2884,6 +3044,214 @@ __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); diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 73049eb5fb..67d1fe4e06 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,6 +36,181 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; +/* +Half Arithmetic Functions +*/ +__device__ static __half __hadd(const __half a, const __half b); +__device__ static __half __hadd_sat(__half a, __half b); +__device__ static __half __hfma(__half a, __half b, __half c); +__device__ static __half __hfma_sat(__half a, __half b, __half c); +__device__ static __half __hmul(__half a, __half b); +__device__ static __half __hmul_sat(__half a, __half b); +__device__ static __half __hneg(__half a); +__device__ static __half __hsub(__half a, __half b); +__device__ static __half __hsub_sat(__half a, __half b); +__device__ static __half hdiv(__half a, __half b); + +/* +Half2 Arithmetic Functions +*/ + +__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" __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); @@ -331,109 +506,7 @@ __device__ static inline __half2 h2trunc(const __half2 h) { return a; } -__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); - -/* -Conversion instructions -*/ -__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); #endif From dc2f0fdeba212066123cf3c3c183a1d027eee144 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 19 Jan 2017 15:04:32 +0530 Subject: [PATCH 018/104] Fixed hipcommander default execution for HCSWAP-106 Change-Id: I9fbd10dfaeeb4928b2ec23ceed131b5200a658f9 [ROCm/hip commit: cc0d2a675390b2d449a99e140f44cb78b776ba2b] --- projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 93642a85c70628610834a4f27337adbcfb3fb06b Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 14 Jan 2017 08:54:18 -0600 Subject: [PATCH 019/104] Fix debug display for Module launch kernels [ROCm/hip commit: 1c73e44ebe0a53329518e7f8d5b2ddd6949c11d3] --- projects/hip/src/hip_module.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 7d77dbe8dd..d6c50e82a9 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -297,8 +297,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 = f._groupSegmentSize; // TODO - this should be part of preLaunchKernel. + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f._name); hsa_kernel_dispatch_packet_t aql; From 5998ca2d85e486cf56c58fe97aa56cea0f8996e4 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 12:33:06 -0600 Subject: [PATCH 020/104] Doc update - describe debug techniques Also tweak sample to remove unneeded HIP_KERNEL_NAME. Comment update [ROCm/hip commit: 1f5d16afe79f7539431e32a2b9c4b0ad18f5cbe2] --- projects/hip/docs/markdown/hip_profiling.md | 48 ++++++++++++++++++- .../samples/0_Intro/square/square.hipref.cpp | 2 +- projects/hip/src/hip_hcc.cpp | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index c198c4dc4b..4119ef47e9 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -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. @@ -362,3 +362,49 @@ TargetAddress:0x5ec7e9000 ... -->0x5ec7e9000-0x5f7e28fff:: allocSeqNum:488 hostPointer:(nil) devicePointer:0x5ec7e9000 sizeBytes:191102976 isInDeviceMem:1 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) ``` +- 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 +... +``` + +Some general 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 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/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index a2383245fc..544fdc110d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -338,6 +338,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); From 584a4a10c1923de4092d918afcc3c138ec930bb1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 19 Jan 2017 15:15:25 -0600 Subject: [PATCH 021/104] added operator overloading for complex data types Change-Id: Id96d5d000651914169f04497af6ff78ad96d846a [ROCm/hip commit: 6ca2b289a212e20642f0bf972957eb70b574a1c3] --- .../hip/include/hip/hcc_detail/hip_complex.h | 161 +++++++++++++++++- 1 file changed, 156 insertions(+), 5 deletions(-) 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; From b6c7c5bd8bef8f6cc5248a7e577b327169de9faf Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 21:26:36 -0600 Subject: [PATCH 022/104] Change ihipDeviceSetState,ihipDevice* so it doesn't log error Cleans up debug trace. [ROCm/hip commit: 8209320ef0854a04362cc81ca9fc570138c607f2] --- projects/hip/src/hip_device.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 131526b6e2..5139eba0af 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,7 +261,7 @@ 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) @@ -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) From 7a402a7fb1d4633452c05ebc15cb2da1354ef4d6 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 23:22:06 -0600 Subject: [PATCH 023/104] Add HIP_SYNC_HOST_ALLOC, HipReadEnv [ROCm/hip commit: 927ac3d81c2105bbf7ffd86434e880ea6456da6f] --- projects/hip/src/hip_hcc.cpp | 37 ++++++++++++++++++++++----------- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_memory.cpp | 9 ++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 544fdc110d..6360097557 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -92,6 +92,10 @@ 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; + @@ -1270,19 +1274,8 @@ std::string HIP_VISIBLE_DEVICES_callback(void *var_ptr, const char *envVarString } -//--- -//Function called one-time at initialization time to construct a table of all GPU devices. -//HIP/CUDA uses integer "deviceIds" - these are indexes into this table. -//AMP maintains a table of accelerators, but some are emulated - ie for debug or CPU. -//This function creates a vector with only the GPU accelerators. -//It is called with C++11 call_once, which provided thread-safety. -void ihipInit() +void HipReadEnv() { - -#if COMPILE_HIP_ATP_MARKER - amdtInitializeActivityLogger(); - amdtScopedMarker("ihipInit", "HIP", NULL); -#endif /* * Environment variables */ @@ -1324,6 +1317,8 @@ void ihipInit() READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); + READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability"); + // TODO - review, can we remove this? READ_ENV_I(release, HIP_NUM_KERNELS_INFLIGHT, 128, "Max number of inflight kernels per stream before active synchronization is forced."); @@ -1375,9 +1370,27 @@ void ihipInit() parseTrigger(HIP_DB_START_API, g_dbStartTriggers); parseTrigger(HIP_DB_STOP_API, g_dbStopTriggers); +}; +//--- +//Function called one-time at initialization time to construct a table of all GPU devices. +//HIP/CUDA uses integer "deviceIds" - these are indexes into this table. +//AMP maintains a table of accelerators, but some are emulated - ie for debug or CPU. +//This function creates a vector with only the GPU accelerators. +//It is called with C++11 call_once, which provided thread-safety. +void ihipInit() +{ + +#if COMPILE_HIP_ATP_MARKER + amdtInitializeActivityLogger(); + amdtScopedMarker("ihipInit", "HIP", NULL); +#endif + + + HipReadEnv(); + /* * Build a table of valid compute devices. diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 031c92fca7..f59019137b 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -62,7 +62,7 @@ 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; // Class to assign a short TID to each new thread, for HIP debugging purposes. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index c43b6991c6..3c727d34fc 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -164,6 +164,10 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int 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); } @@ -993,6 +1000,8 @@ hipError_t hipHostFree(void* ptr) return ihipLogStatus(hipStatus); }; + +// Deprecated: hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); From f5e3b72d0a6b4b17ac463eb0de6fe1a116bba13a Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 09:49:11 -0600 Subject: [PATCH 024/104] fixed compilation issues for vector types and math functions 1. Added math_functions.h to hip_runtime.h 2. Changed operator overloading classifier static to static inline 3. Added vector types test for gpu 4. Seperated __host__ and __device__ for math functions in headers Change-Id: I499862fad5d7b10da686da9011d7ecefe523f8e2 [ROCm/hip commit: f537d96633cf6ef1d2ca36f7de280cd0fefaf7a9] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 2 + .../include/hip/hcc_detail/hip_vector_types.h | 40 +- .../include/hip/hcc_detail/math_functions.h | 35 +- projects/hip/src/math_functions.cpp | 12 +- .../tests/src/deviceLib/hipVectorTypes.cpp | 1981 +++++---- .../src/deviceLib/hipVectorTypesDevice.cpp | 3880 +++++++++++++++++ 6 files changed, 4942 insertions(+), 1008 deletions(-) create mode 100644 projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f11846a0da..909b7f5680 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -69,6 +69,8 @@ extern int HIP_TRACE_API; #include #endif #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__ 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..3e3acb8f29 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -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/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index b07830958f..2755c896db 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -36,7 +36,7 @@ __device__ float ceilf(float x); __device__ float copysignf(float x, float y); __device__ float cosf(float x); __device__ float coshf(float x); -__device__ __host__ float cospif(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); @@ -50,7 +50,7 @@ __device__ float expf(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 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); @@ -59,7 +59,7 @@ __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__ __host__ int isfinite(float a); +__device__ int isfinite(float a); __device__ unsigned isinf(float a); __device__ unsigned isnan(float a); __device__ float j0f(float x); @@ -93,15 +93,15 @@ __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__ __host__ float rsqrtf(float x); +__device__ float rsqrtf(float x); __device__ float scalblnf(float x, long int n); __device__ float scalbnf(float x, int n); -__device__ __host__ unsigned signbit(float a); +__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__ __host__ float sinpif(float x); +__device__ float sinpif(float x); __device__ float sqrtf(float x); __device__ float tanf(float x); __device__ float tanhf(float x); @@ -111,11 +111,12 @@ __device__ float y0f(float x); __device__ float y1f(float x); __device__ float ynf(int n, float x); - +__host__ float cospif(float x); __host__ float normcdff(float y); __host__ float erfcinvf(float y); __host__ float erfcxf(float x); __host__ float erfinvf(float y); +__host__ float fdividef(float x, float y); __host__ float norm3df(float a, float b, float c); __host__ float normcdfinvf(float y); __host__ float norm4df(float a, float b, float c, float d); @@ -125,7 +126,10 @@ __host__ float rnorm3df(float a, float b, float c); __host__ float rnormf(int dim, const float* a); __host__ float rnorm4df(float a, float b, float c, float d); __host__ void sincospif(float x, float *sptr, float *cptr); - +__host__ int isfinite(float a); +__host__ float rsqrtf(float x); +__host__ float sinpif(float x); +__host__ int signbit(float a); __device__ double acos(double x); @@ -140,7 +144,7 @@ __device__ double ceil(double x); __device__ double copysign(double x, double y); __device__ double cos(double x); __device__ double cosh(double x); -__device__ __host__ double cospi(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); @@ -162,7 +166,7 @@ __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__ __host__ unsigned isfinite(double x); +__device__ int isfinite(double x); __device__ unsigned isinf(double x); __device__ unsigned isnan(double x); __device__ double j0(double x); @@ -198,15 +202,15 @@ __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__ __host__ double rsqrt(double x); +__device__ double rsqrt(double x); __device__ double scalbln(double x, long int n); __device__ double scalbn(double x, int n); -__device__ __host__ unsigned signbit(double a); +__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__ __host__ double sinpi(double x); +__device__ double sinpi(double x); __device__ double sqrt(double x); __device__ double tan(double x); __device__ double tanh(double x); @@ -231,6 +235,11 @@ __host__ double rnorm(int dim, const double* t); __host__ double rnorm3d(double a, double b, double c); __host__ double rnorm4d(double a, double b, double c, double d); __host__ void sincospi(double x, double *sptr, double *cptr); +__host__ double cospi(double x); +__host__ int isfinite(double x); +__host__ double rsqrt(double x); +__host__ int signbit(double a); +__host__ double sinpi(double x); // ENDPARSER diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 130d4152ae..a1ee9d3ce5 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -158,7 +158,7 @@ __device__ float ilogbf(float x) { return hc::precise_math::ilogbf(x); } -__device__ unsigned isfinite(float a) +__device__ int isfinite(float a) { return hc::precise_math::isfinite(a); } @@ -334,7 +334,7 @@ __device__ float scalbnf(float x, int n) { return hc::precise_math::scalbnf(x, n); } -__device__ unsigned signbit(float a) +__device__ int signbit(float a) { return hc::precise_math::signbit(a); } @@ -539,7 +539,7 @@ __device__ double ilogb(double x) { return hc::precise_math::ilogb(x); } -__device__ unsigned isfinite(double x) +__device__ int isfinite(double x) { return hc::precise_math::isfinite(x); } @@ -712,7 +712,7 @@ __device__ double scalbn(double x, int n) { return hc::precise_math::scalbn(x, n); } -__device__ unsigned signbit(double x) +__device__ int signbit(double x) { return hc::precise_math::signbit(x); } @@ -792,7 +792,7 @@ __host__ int signbit(float x) return std::signbit(x); } -__host__ int sinpif(float x) +__host__ float sinpif(float x) { return std::sin(x*HIP_PI); } @@ -984,7 +984,7 @@ __host__ double cospi(double a) return std::cos(HIP_PI * a); } -__host__ double isfinite(double a) +__host__ int isfinite(double a) { return std::isfinite(a); } diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp index 0e5757b30d..957439c27e 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); + +// signed char sc = 1; f1.x = 3; f2.x = 4; @@ -137,72 +182,72 @@ 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; @@ -232,19 +277,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 +297,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,47 +308,47 @@ 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; @@ -338,19 +383,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 +405,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,49 +418,49 @@ 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; @@ -447,66 +492,66 @@ bool TestChar1() { 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; @@ -531,72 +576,72 @@ 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; @@ -626,19 +671,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 +691,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,47 +702,47 @@ 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; @@ -732,19 +777,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 +799,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,49 +812,49 @@ 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; @@ -841,66 +886,66 @@ bool TestUShort1() { 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; @@ -925,72 +970,72 @@ 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; @@ -1020,19 +1065,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 +1085,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,47 +1096,47 @@ 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; @@ -1126,19 +1171,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 +1193,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,49 +1206,49 @@ 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; @@ -1235,66 +1280,66 @@ bool TestShort1() { 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; @@ -1319,72 +1364,72 @@ 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); f1.x = 3; @@ -1414,19 +1459,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 +1479,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,47 +1490,47 @@ 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; @@ -1520,19 +1565,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 +1587,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,49 +1600,49 @@ 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; @@ -1630,66 +1675,66 @@ 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; @@ -1714,72 +1759,72 @@ 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; @@ -1809,19 +1854,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 +1874,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,47 +1885,47 @@ 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; @@ -1915,19 +1960,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 +1982,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,49 +1995,49 @@ 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; @@ -2024,66 +2069,66 @@ bool TestInt1() { 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; @@ -2108,72 +2153,72 @@ 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; @@ -2203,19 +2248,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 +2268,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,47 +2279,47 @@ 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; @@ -2309,19 +2354,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 +2376,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,49 +2389,49 @@ 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; @@ -2418,66 +2463,66 @@ bool TestULong1() { 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; @@ -2502,72 +2547,72 @@ 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; @@ -2597,19 +2642,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 +2662,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,47 +2673,47 @@ 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; @@ -2703,19 +2748,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 +2770,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,49 +2783,49 @@ 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; @@ -2812,66 +2857,66 @@ bool TestLong1() { 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; @@ -2896,72 +2941,72 @@ 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; @@ -2991,19 +3036,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 +3056,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,47 +3067,47 @@ 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; @@ -3097,19 +3142,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 +3164,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,49 +3177,49 @@ 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; @@ -3205,39 +3250,39 @@ bool TestLong4() { bool TestFloat1() { float1 f1, f2, f3; // float1 f4(1); -// cmpFloat1(f4, 1.0f); +// cmpVal1(f4, 1.0f); // float1 f5(2.0f); -// cmpFloat1(f5, 2.0f); +// cmpVal1(f5, 2.0f); f1.x = 1.0f; f2.x = 1.0f; f3 = f1 + f2; - cmpFloat1(f3, 2.0f); + cmpVal1(f3, 2.0f); f2 = f3 - f1; - cmpFloat1(f2, 1.0f); + cmpVal1(f2, 1.0f); f1 = f2 * f3; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f2 = f1 / f3; - cmpFloat1(f2, 2.0f/2.0f); + cmpVal1(f2, 2.0f/2.0f); f1 += f2; - cmpFloat1(f1, 3.0f); + cmpVal1(f1, 3.0f); f1 -= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1 *= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1 /= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f2 = f1++; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 2.0f); + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); f2 = f1--; - cmpFloat1(f2, 3.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); f2 = ++f1; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 3.0f); + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); f2 = --f1; - cmpFloat1(f1, 2.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1.x = 3.0f; f2.x = 4.0f; @@ -3259,34 +3304,34 @@ bool TestFloat2() { f2.x = 1.0f; f2.y = 1.0f; f3 = f1 + f2; - cmpFloat2(f3, 2.0f); + cmpVal2(f3, 2.0f); f2 = f3 - f1; - cmpFloat2(f2, 1.0f); + cmpVal2(f2, 1.0f); f1 = f2 * f3; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f2 = f1 / f3; - cmpFloat2(f2, 2.0f/2.0f); + cmpVal2(f2, 2.0f/2.0f); f1 += f2; - cmpFloat2(f1, 3.0f); + cmpVal2(f1, 3.0f); f1 -= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1 *= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1 /= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f2 = f1++; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 2.0f); + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); f2 = f1--; - cmpFloat2(f2, 3.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); f2 = ++f1; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 3.0f); + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); f2 = --f1; - cmpFloat2(f1, 2.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3314,32 +3359,32 @@ bool TestFloat3() { f2.y = 1.0f; f2.z = 1.0f; f3 = f1 + f2; - cmpFloat3(f3, 2.0f); + cmpVal3(f3, 2.0f); f2 = f3 - f1; - cmpFloat3(f2, 1.0f); + cmpVal3(f2, 1.0f); f1 = f2 * f3; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f2 = f1 / f3; - cmpFloat3(f2, 2.0f/2.0f); + cmpVal3(f2, 2.0f/2.0f); f1 += f2; - cmpFloat3(f1, 3.0f); + cmpVal3(f1, 3.0f); f1 -= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1 *= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1 /= f2; f2 = f1++; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 2.0f); + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); f2 = f1--; - cmpFloat3(f2, 3.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); f2 = ++f1; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 3.0f); + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); f2 = --f1; - cmpFloat3(f1, 2.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3373,32 +3418,32 @@ bool TestFloat4() { f2.z = 1.0f; f2.w = 1.0f; f3 = f1 + f2; - cmpFloat4(f3, 2.0f); + cmpVal4(f3, 2.0f); f2 = f3 - f1; - cmpFloat4(f2, 1.0f); + cmpVal4(f2, 1.0f); f1 = f2 * f3; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f2 = f1 / f3; - cmpFloat4(f2, 2.0f/2.0f); + cmpVal4(f2, 2.0f/2.0f); f1 += f2; - cmpFloat4(f1, 3.0f); + cmpVal4(f1, 3.0f); f1 -= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1 *= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1 /= f2; f2 = f1++; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 2.0f); + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); f2 = f1--; - cmpFloat4(f2, 3.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); f2 = ++f1; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 3.0f); + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); f2 = --f1; - cmpFloat4(f1, 2.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3422,8 +3467,6 @@ bool TestFloat4() { return true; } - - int main() { assert(sizeof(float1) == 4); assert(sizeof(float2) == 8); @@ -3438,6 +3481,6 @@ int main() { && TestInt1() && TestInt2() && TestInt3() && TestInt4() && TestULong1() && TestULong2() && TestULong3() && TestULong4() && TestLong1() && TestLong2() && TestLong3() && TestLong4() == 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(); +} From 6119b9c47539f69d0467f5bf581a6b5697fd7e95 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 13:52:02 -0600 Subject: [PATCH 025/104] added more test coverage for vector data types Change-Id: I9f57a8b597bd2ee4b265eadfd0859531497a6ada [ROCm/hip commit: b134a1a640547a06b63cdab5169571d275f81859] --- .../tests/src/deviceLib/hipVectorTypes.cpp | 4606 ++++++++++++++++- 1 file changed, 4479 insertions(+), 127 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp index 957439c27e..12a8cc76a3 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -157,8 +157,28 @@ bool TestUChar1() { 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); -// signed char sc = 1; f1.x = 3; f2.x = 4; @@ -250,6 +270,79 @@ bool TestUChar2() { 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; @@ -351,6 +444,79 @@ bool TestUChar3() { 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; @@ -463,6 +629,81 @@ bool TestUChar4() { 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; @@ -487,6 +728,7 @@ bool TestUChar4() { return true; } + bool TestChar1() { char1 f1, f2, f3; f1.x = 1; @@ -554,6 +796,66 @@ bool TestChar1() { 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; @@ -644,6 +946,79 @@ bool TestChar2() { 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; @@ -745,6 +1120,80 @@ bool TestChar3() { 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; @@ -857,6 +1306,81 @@ bool TestChar4() { 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; @@ -881,6 +1405,7 @@ bool TestChar4() { return true; } + bool TestUShort1() { ushort1 f1, f2, f3; f1.x = 1; @@ -948,6 +1473,66 @@ bool TestUShort1() { 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; @@ -1038,6 +1623,79 @@ bool TestUShort2() { 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; @@ -1139,6 +1797,80 @@ bool TestUShort3() { 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; @@ -1251,6 +1983,80 @@ bool TestUShort4() { 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; @@ -1275,6 +2081,7 @@ bool TestUShort4() { return true; } + bool TestShort1() { short1 f1, f2, f3; f1.x = 1; @@ -1342,6 +2149,66 @@ bool TestShort1() { 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; @@ -1432,6 +2299,80 @@ bool TestShort2() { 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; @@ -1533,6 +2474,79 @@ bool TestShort3() { 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; @@ -1645,6 +2659,81 @@ bool TestShort4() { 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; @@ -1737,6 +2826,66 @@ bool TestUInt1() { 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; @@ -1827,6 +2976,79 @@ bool TestUInt2() { 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; @@ -1928,6 +3150,80 @@ bool TestUInt3() { 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; @@ -2040,6 +3336,81 @@ bool TestUInt4() { 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; @@ -2064,6 +3435,7 @@ bool TestUInt4() { return true; } + bool TestInt1() { int1 f1, f2, f3; f1.x = 1; @@ -2131,6 +3503,66 @@ bool TestInt1() { 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; @@ -2221,6 +3653,79 @@ bool TestInt2() { 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; @@ -2322,6 +3827,80 @@ bool TestInt3() { 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; @@ -2434,6 +4013,81 @@ bool TestInt4() { 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; @@ -2458,6 +4112,505 @@ 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; @@ -2525,6 +4678,66 @@ bool TestULong1() { 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; @@ -2615,6 +4828,79 @@ bool TestULong2() { 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; @@ -2716,6 +5002,80 @@ bool TestULong3() { 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; @@ -2828,6 +5188,81 @@ bool TestULong4() { 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; @@ -2852,6 +5287,7 @@ bool TestULong4() { return true; } + bool TestLong1() { long1 f1, f2, f3; f1.x = 1; @@ -2919,6 +5355,66 @@ bool TestLong1() { 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; @@ -3009,6 +5505,79 @@ bool TestLong2() { 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; @@ -3110,6 +5679,80 @@ bool TestLong3() { 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; @@ -3222,6 +5865,81 @@ bool TestLong4() { 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; @@ -3247,46 +5965,102 @@ bool TestLong4() { } -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; +bool TestDouble1() { + double1 f1, f2, f3; + f1.x = 1.0; + f2.x = 1.0; f3 = f1 + f2; - cmpVal1(f3, 2.0f); + cmpVal1(f3, 2.0); f2 = f3 - f1; - cmpVal1(f2, 1.0f); + cmpVal1(f2, 1.0); f1 = f2 * f3; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1 / f3; - cmpVal1(f2, 2.0f/2.0f); + cmpVal1(f2, 2.0/2.0); f1 += f2; - cmpVal1(f1, 3.0f); + cmpVal1(f1, 3.0); f1 -= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 *= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 /= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1++; - cmpVal1(f1, 3.0f); - cmpVal1(f2, 2.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 2.0); f2 = f1--; - cmpVal1(f2, 3.0f); - cmpVal1(f1, 2.0f); + cmpVal1(f2, 3.0); + cmpVal1(f1, 2.0); f2 = ++f1; - cmpVal1(f1, 3.0f); - cmpVal1(f2, 3.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 3.0); f2 = --f1; - cmpVal1(f1, 2.0f); - cmpVal1(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); @@ -3297,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; - cmpVal2(f3, 2.0f); + cmpVal2(f3, 2.0); f2 = f3 - f1; - cmpVal2(f2, 1.0f); + cmpVal2(f2, 1.0); f1 = f2 * f3; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1 / f3; - cmpVal2(f2, 2.0f/2.0f); + cmpVal2(f2, 2.0f/2.0); f1 += f2; - cmpVal2(f1, 3.0f); + cmpVal2(f1, 3.0); f1 -= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 *= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 /= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1++; - cmpVal2(f1, 3.0f); - cmpVal2(f2, 2.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 2.0); f2 = f1--; - cmpVal2(f2, 3.0f); - cmpVal2(f1, 2.0f); + cmpVal2(f2, 3.0); + cmpVal2(f1, 2.0); f2 = ++f1; - cmpVal2(f1, 3.0f); - cmpVal2(f2, 3.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 3.0); f2 = --f1; - cmpVal2(f1, 2.0f); - cmpVal2(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); @@ -3350,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; - cmpVal3(f3, 2.0f); + cmpVal3(f3, 2.0); f2 = f3 - f1; - cmpVal3(f2, 1.0f); + cmpVal3(f2, 1.0); f1 = f2 * f3; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f2 = f1 / f3; - cmpVal3(f2, 2.0f/2.0f); + cmpVal3(f2, 2.0f/2.0); f1 += f2; - cmpVal3(f1, 3.0f); + cmpVal3(f1, 3.0); f1 -= f2; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 *= f2; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 /= f2; f2 = f1++; - cmpVal3(f1, 3.0f); - cmpVal3(f2, 2.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 2.0); f2 = f1--; - cmpVal3(f2, 3.0f); - cmpVal3(f1, 2.0f); + cmpVal3(f2, 3.0); + cmpVal3(f1, 2.0); f2 = ++f1; - cmpVal3(f1, 3.0f); - cmpVal3(f2, 3.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 3.0); f2 = --f1; - cmpVal3(f1, 2.0f); - cmpVal3(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); @@ -3406,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; - cmpVal4(f3, 2.0f); + cmpVal4(f3, 2.0); f2 = f3 - f1; - cmpVal4(f2, 1.0f); + cmpVal4(f2, 1.0); f1 = f2 * f3; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f2 = f1 / f3; - cmpVal4(f2, 2.0f/2.0f); + cmpVal4(f2, 2.0f/2.0); f1 += f2; - cmpVal4(f1, 3.0f); + cmpVal4(f1, 3.0); f1 -= f2; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 *= f2; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 /= f2; f2 = f1++; - cmpVal4(f1, 3.0f); - cmpVal4(f2, 2.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 2.0); f2 = f1--; - cmpVal4(f2, 3.0f); - cmpVal4(f1, 2.0f); + cmpVal4(f2, 3.0); + cmpVal4(f1, 2.0); f2 = ++f1; - cmpVal4(f1, 3.0f); - cmpVal4(f2, 3.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 3.0); f2 = --f1; - cmpVal4(f1, 2.0f); - cmpVal4(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); @@ -3467,12 +6462,1367 @@ bool TestFloat4() { return true; } + +bool TestULongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ulonglong1 fa((unsigned char)1); + ulonglong1 fb((signed char)1); + ulonglong1 fc((unsigned short)1); + ulonglong1 fd((signed short)1); + ulonglong1 fe((unsigned int)1); + ulonglong1 fg((signed int)1); + ulonglong1 fh((float)1); + ulonglong1 fi((double)1); + ulonglong1 fj((unsigned long)1); + ulonglong1 fk((signed long)1); + ulonglong1 fl((unsigned long long)1); + ulonglong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ulonglong2 fa1((unsigned char)1); + ulonglong2 fa2((unsigned char)1, (unsigned char)1); + ulonglong2 fb1((signed char)1); + ulonglong2 fb2((signed char)1, (signed char)1); + ulonglong2 fc1((unsigned short)1); + ulonglong2 fc2((unsigned short)1,(unsigned short)1); + ulonglong2 fd1((signed short)1); + ulonglong2 fd2((signed short)1, (signed short)1); + ulonglong2 fe1((unsigned int)1); + ulonglong2 fe2((unsigned int)1, (unsigned int)1); + ulonglong2 fg1((signed int)1); + ulonglong2 fg2((signed int)1, (signed int)1); + ulonglong2 fh1((float)1); + ulonglong2 fh2((float)1, (float)1); + ulonglong2 fi1((double)1); + ulonglong2 fi2((double)1, (double)1); + ulonglong2 fj1((unsigned long)1); + ulonglong2 fj2((unsigned long)1, (unsigned long)1); + ulonglong2 fk1((signed long)1); + ulonglong2 fk2((signed long)1, (signed long)1); + ulonglong2 fl1((unsigned long long)1); + ulonglong2 fl2((unsigned long long)1, (unsigned long long)1); + ulonglong2 fm1((signed long long)1); + ulonglong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ulonglong3 fa1((unsigned char)1); + ulonglong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong3 fb1((signed char)1); + ulonglong3 fb2((signed char)1, (signed char)1, (signed char)1); + ulonglong3 fc1((unsigned short)1); + ulonglong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong3 fd1((signed short)1); + ulonglong3 fd2((signed short)1, (signed short)1, (signed short)1); + ulonglong3 fe1((unsigned int)1); + ulonglong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong3 fg1((signed int)1); + ulonglong3 fg2((signed int)1, (signed int)1, (signed int)1); + ulonglong3 fh1((float)1); + ulonglong3 fh2((float)1, (float)1, (float)1); + ulonglong3 fi1((double)1); + ulonglong3 fi2((double)1, (double)1, (double)1); + ulonglong3 fj1((unsigned long)1); + ulonglong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong3 fk1((signed long)1); + ulonglong3 fk2((signed long)1, (signed long)1, (signed long)1); + ulonglong3 fl1((unsigned long long)1); + ulonglong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong3 fm1((signed long long)1); + ulonglong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ulonglong4 fa1((unsigned char)1); + ulonglong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong4 fb1((signed char)1); + ulonglong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ulonglong4 fc1((unsigned short)1); + ulonglong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong4 fd1((signed short)1); + ulonglong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ulonglong4 fe1((unsigned int)1); + ulonglong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong4 fg1((signed int)1); + ulonglong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ulonglong4 fh1((float)1); + ulonglong4 fh2((float)1, (float)1, (float)1, (float)1); + ulonglong4 fi1((double)1); + ulonglong4 fi2((double)1, (double)1, (double)1, (double)1); + ulonglong4 fj1((unsigned long)1); + ulonglong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong4 fk1((signed long)1); + ulonglong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ulonglong4 fl1((unsigned long long)1); + ulonglong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong4 fm1((signed long long)1); + ulonglong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestLongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + longlong1 fa((unsigned char)1); + longlong1 fb((signed char)1); + longlong1 fc((unsigned short)1); + longlong1 fd((signed short)1); + longlong1 fe((unsigned int)1); + longlong1 fg((signed int)1); + longlong1 fh((float)1); + longlong1 fi((double)1); + longlong1 fj((unsigned long)1); + longlong1 fk((signed long)1); + longlong1 fl((unsigned long long)1); + longlong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + longlong2 fa1((unsigned char)1); + longlong2 fa2((unsigned char)1, (unsigned char)1); + longlong2 fb1((signed char)1); + longlong2 fb2((signed char)1, (signed char)1); + longlong2 fc1((unsigned short)1); + longlong2 fc2((unsigned short)1,(unsigned short)1); + longlong2 fd1((signed short)1); + longlong2 fd2((signed short)1, (signed short)1); + longlong2 fe1((unsigned int)1); + longlong2 fe2((unsigned int)1, (unsigned int)1); + longlong2 fg1((signed int)1); + longlong2 fg2((signed int)1, (signed int)1); + longlong2 fh1((float)1); + longlong2 fh2((float)1, (float)1); + longlong2 fi1((double)1); + longlong2 fi2((double)1, (double)1); + longlong2 fj1((unsigned long)1); + longlong2 fj2((unsigned long)1, (unsigned long)1); + longlong2 fk1((signed long)1); + longlong2 fk2((signed long)1, (signed long)1); + longlong2 fl1((unsigned long long)1); + longlong2 fl2((unsigned long long)1, (unsigned long long)1); + longlong2 fm1((signed long long)1); + longlong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + longlong3 fa1((unsigned char)1); + longlong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong3 fb1((signed char)1); + longlong3 fb2((signed char)1, (signed char)1, (signed char)1); + longlong3 fc1((unsigned short)1); + longlong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong3 fd1((signed short)1); + longlong3 fd2((signed short)1, (signed short)1, (signed short)1); + longlong3 fe1((unsigned int)1); + longlong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong3 fg1((signed int)1); + longlong3 fg2((signed int)1, (signed int)1, (signed int)1); + longlong3 fh1((float)1); + longlong3 fh2((float)1, (float)1, (float)1); + longlong3 fi1((double)1); + longlong3 fi2((double)1, (double)1, (double)1); + longlong3 fj1((unsigned long)1); + longlong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong3 fk1((signed long)1); + longlong3 fk2((signed long)1, (signed long)1, (signed long)1); + longlong3 fl1((unsigned long long)1); + longlong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong3 fm1((signed long long)1); + longlong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + longlong4 fa1((unsigned char)1); + longlong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong4 fb1((signed char)1); + longlong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + longlong4 fc1((unsigned short)1); + longlong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong4 fd1((signed short)1); + longlong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + longlong4 fe1((unsigned int)1); + longlong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong4 fg1((signed int)1); + longlong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + longlong4 fh1((float)1); + longlong4 fh2((float)1, (float)1, (float)1, (float)1); + longlong4 fi1((double)1); + longlong4 fi2((double)1, (double)1, (double)1, (double)1); + longlong4 fj1((unsigned long)1); + longlong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong4 fk1((signed long)1); + longlong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + longlong4 fl1((unsigned long long)1); + longlong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong4 fm1((signed long long)1); + longlong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + int main() { assert(sizeof(float1) == 4); assert(sizeof(float2) == 8); assert(sizeof(float3) == 12); assert(sizeof(float4) == 16); assert(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestDouble1() && TestDouble2() && TestDouble3() && TestDouble4() && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() && TestChar1() && TestChar2() && TestChar3() && TestChar4() && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() @@ -3480,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); } From 35d8bac54280fd88a11c6d5963e062f33321d1f1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 14:11:45 -0600 Subject: [PATCH 026/104] added nvcc backend for hipArrays 1. Added hip_texture.h to hip_runtime_api.h as cuda does declare array runtime apis inside cuda_runtime_api.h 2. Added nvcc backend for hipArray runtime apis 3. Didn't test on nvidia platform (should work) Change-Id: I1a14aef41840e4f55e5535132e3443a918b55967 [ROCm/hip commit: b1eca6c855fbc8444aa62b75551d7d3ea33bd23b] --- .../include/hip/hcc_detail/hip_runtime_api.h | 1 + .../include/hip/nvcc_detail/hip_runtime_api.h | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) 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..448102a1c6 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -33,6 +33,7 @@ THE SOFTWARE. #include #include +#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); 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..482e91e440 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -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_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, width, height, 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, kind)); +} + +inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, kind)); +} + inline static hipError_t hipDeviceSynchronize() { return hipCUDAErrorTohipError(cudaDeviceSynchronize()); } From 83260101e1f540a0f803d506259b326136a46c72 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 14:19:09 -0600 Subject: [PATCH 027/104] changes device functions documentation according to the supported apis Change-Id: I47ac6bbde11d54d8265e0d27ec8cd5da4d03eb8e [ROCm/hip commit: 7765469987fe1745db38556850f496e04cb6f7f9] --- projects/hip/docs/markdown/hip-math-api.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md index 6a8e90eb59..37efafbbbf 100644 --- a/projects/hip/docs/markdown/hip-math-api.md +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -118,7 +118,7 @@ __device__ float coshf(float x); ### cospif ```cpp -__device__ __host__ float cospif(float x); +__device__ float cospif(float x); ``` **Description:** Supported @@ -230,7 +230,7 @@ __device__ float fdimf(float x, float y); ### fdividef ```cpp -__device__ __host__ float fdividef(float x, float y); +__device__ float fdividef(float x, float y); ``` **Description:** Supported @@ -302,7 +302,7 @@ __device__ float ilogbf(float x); ### isfinite ```cpp -__device__ __host__ int isfinite(float a); +__device__ int isfinite(float a); ``` **Description:** Supported @@ -574,7 +574,7 @@ __device__ float roundf(float x); ### rsqrtf ```cpp -__device__ __host__ float rsqrtf(float x); +__device__ float rsqrtf(float x); ``` **Description:** Supported @@ -598,7 +598,7 @@ __device__ float scalbnf(float x, int n); ### signbit ```cpp -__device__ __host__ unsigned signbit(float a); +__device__ int signbit(float a); ``` **Description:** Supported @@ -638,7 +638,7 @@ __device__ float sinhf(float x); ### sinpif ```cpp -__device__ __host__ float sinpif(float x); +__device__ float sinpif(float x); ``` **Description:** Supported @@ -806,7 +806,7 @@ __device__ double cosh(double x); ### cospi ```cpp -__device__ __host__ double cospi(double x); +__device__ double cospi(double x); ``` **Description:** Supported @@ -982,7 +982,7 @@ __device__ double ilogb(double x); ### isfinite ```cpp -__device__ __host__ unsigned isfinite(double x); +__device__ int isfinite(double x); ``` **Description:** Supported @@ -1270,7 +1270,7 @@ __device__ double round(double x); ### rsqrt ```cpp -__device__ __host__ double rsqrt(double x); +__device__ double rsqrt(double x); ``` **Description:** Supported @@ -1294,7 +1294,7 @@ __device__ double scalbn(double x, int n); ### signbit ```cpp -__device__ __host__ unsigned signbit(double a); +__device__ int signbit(double a); ``` **Description:** Supported @@ -1334,7 +1334,7 @@ __device__ double sinh(double x); ### sinpi ```cpp -__device__ __host__ double sinpi(double x); +__device__ double sinpi(double x); ``` **Description:** Supported From d48571b65bc7a8758e5ed94d32d380684af5d6f6 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 16:54:48 -0600 Subject: [PATCH 028/104] fixed hipArray issues 1. Fixed build issues produced from previous commit 2. Create new header files to manage data structures better Change-Id: I704d82c196c1858ed7617d76e40612eb507d2aa0 [ROCm/hip commit: 22acd654cf788dd3435d41b13f376617ec9a10b2] --- projects/hip/include/hip/channel_descriptor.h | 36 ++ .../hip/hcc_detail/channel_descriptor.h | 374 ++++++++++++++++++ .../hip/include/hip/hcc_detail/driver_types.h | 41 ++ .../include/hip/hcc_detail/hip_runtime_api.h | 171 +++++++- .../hip/include/hip/hcc_detail/hip_texture.h | 238 +---------- .../include/hip/hcc_detail/texture_types.h | 42 ++ projects/hip/include/hip/math_functions.h | 13 - .../hip/nvcc_detail/channel_descriptor.h | 25 ++ .../include/hip/nvcc_detail/hip_runtime_api.h | 2 +- 9 files changed, 691 insertions(+), 251 deletions(-) create mode 100644 projects/hip/include/hip/channel_descriptor.h create mode 100644 projects/hip/include/hip/hcc_detail/channel_descriptor.h create mode 100644 projects/hip/include/hip/hcc_detail/driver_types.h create mode 100644 projects/hip/include/hip/hcc_detail/texture_types.h create mode 100644 projects/hip/include/hip/nvcc_detail/channel_descriptor.h 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/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h new file mode 100644 index 0000000000..91d48af4cf --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -0,0 +1,374 @@ +/* +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 + +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); + +template +static inline hipChannelFormatDesc hipCreateChannelDesc() { + return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); +} + +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<> +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); +} + +#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_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 448102a1c6..f9ab03901a 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. @@ -177,6 +177,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; + hipChannelFormatKind f; + void* data; //FIXME: generalize this +} hipArray; @@ -1235,6 +1241,84 @@ 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 + */ +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); + + + // doxygen end Memory /** * @} @@ -1911,6 +1995,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..bd44206be4 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,16 @@ THE SOFTWARE. */ #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 +52,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 +97,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 +104,3 @@ hipError_t hipUnbindTexture(struct texture &tex) */ #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..d9221dc009 --- /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 { + hipTextureFilterMode filterMode; + bool normalized; + hipChannelFormatDesc channelDesc; +}; + +#endif diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h index d33f7a2e90..6afe463a5d 100644 --- a/projects/hip/include/hip/math_functions.h +++ b/projects/hip/include/hip/math_functions.h @@ -20,19 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -//! HIP = Heterogeneous-compute Interface for Portability -//! -//! Define a extremely thin runtime layer that allows source code to be compiled unmodified -//! through either AMD HCC or NVCC. Key features tend to be in the spirit -//! and terminology of CUDA, but with a portable path to other accelerators as well: -// -//! Both paths support rich C++ features including classes, templates, lambdas, etc. -//! Runtime API is C -//! Memory management is based on pure pointers and resembles malloc/free/copy. -// -//! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. -//! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. - #pragma once // Some standard header files, these are included by hc.hpp and so want to make them avail on both 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 482e91e440..3cd5667175 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 From ed03475a09db87c1d60634e34abdc04a1391426c Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 17:09:52 -0600 Subject: [PATCH 029/104] added driver_types.h and texture_types.h header files to hip Change-Id: Ic3b2403f07d6767dadf83d6c278fd14e87f6acdb [ROCm/hip commit: 8ddec0426ba9d23fe45caa03c2200aeb49e104c6] --- projects/hip/include/hip/driver_types.h | 29 +++++++++++++++++++++++ projects/hip/include/hip/texture_types.h | 30 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 projects/hip/include/hip/driver_types.h create mode 100644 projects/hip/include/hip/texture_types.h 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/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 From b7340001099883f6ae12b28c59de8e337af2270e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 17:21:51 -0600 Subject: [PATCH 030/104] added ir code sad u8 Change-Id: Ie0d454b3bb9a6c9a028c091ad3aa969719b02cc9 [ROCm/hip commit: 4e3afa65140520feba7712a0f123d8ea29b80c28] --- projects/hip/src/hip_ir.ll | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index a20b57016e..c68e9879f2 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -171,4 +171,9 @@ define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { ret i32 %1 } +define i32 @__hip_hc_ir_sadu8_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_sad_u8 $0, $1, $2 $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + ret i32 %1 +} + attributes #1 = { alwaysinline nounwind } From bda5602f066e4fd3a96690e7485eca5345b5a408 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:37:39 -0600 Subject: [PATCH 031/104] Add HIP_IGNORE_HCC_VERSION. Ignores strict checking of HCC and HIP version. Can be useful when developing new HCC code. [ROCm/hip commit: 138cf3654738f0d00950dbb016ea9fe88d340148] --- projects/hip/bin/hipcc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index de8f0cb9a3..004463bc2c 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -374,7 +374,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 (); } From c275c0ff72e0e2ace54653c3bf07adc6aefc2e78 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:38:35 -0600 Subject: [PATCH 032/104] Log error with ihipLogError. Cleans up CXL trace display. [ROCm/hip commit: 4586091dfe922183287f21837b0cc703eac7834f] --- projects/hip/src/hip_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 5139eba0af..3cefca82e7 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -267,7 +267,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device 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) From d1c61adcf9fc83ba609fad6ce11f10017da23b13 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:39:45 -0600 Subject: [PATCH 033/104] Add debug tips to docs [ROCm/hip commit: 85d41dcd056089a81ceb32a351eef640d3293ab4] --- projects/hip/docs/markdown/hip_profiling.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 4119ef47e9..772f762912 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -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'): @@ -399,7 +400,7 @@ Program received signal SIGABRT, Aborted. ... ``` -Some general tips: +### 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: @@ -408,3 +409,15 @@ Some general tips: - 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. + + + From f9ecf383e37ea11b56ab3799c6faa16b388d24e1 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:48:29 -0600 Subject: [PATCH 034/104] Add debug tips to docs [ROCm/hip commit: 96eac6792994688871896e60787973db67a6c8dc] --- projects/hip/src/hip_hcc.cpp | 2 +- projects/hip/src/hip_hcc.h | 123 +++++++++++++++++++------------- projects/hip/src/hip_memory.cpp | 42 +++++------ 3 files changed, 97 insertions(+), 70 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 6360097557..c84b93b503 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1475,7 +1475,7 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t stream) void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, const hipStream_t stream) { - if (HIP_PROFILE_API || (COMPILE_HIP_DB && HIP_TRACE_API)) { + if ((HIP_TRACE_API & (1<>%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 +195,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 +229,74 @@ 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 { diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 3c727d34fc..d66c151266 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -160,7 +160,7 @@ 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; @@ -239,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; @@ -291,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; @@ -438,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) { @@ -466,7 +466,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou 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) { @@ -506,7 +506,7 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ //--- 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); @@ -527,7 +527,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); @@ -548,7 +548,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); @@ -569,7 +569,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); @@ -590,7 +590,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); @@ -641,7 +641,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)); @@ -650,21 +650,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)); } @@ -673,7 +673,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); @@ -699,7 +699,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); @@ -752,7 +752,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); @@ -811,7 +811,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; @@ -861,12 +861,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) { From 3be19a4ffa6005687460c5a0adbd3ec2a49cc4df Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 21:19:52 -0600 Subject: [PATCH 035/104] Move core env var processing to env.cpp [ROCm/hip commit: 0dabdeb01f8725089262f14110191c8cf27d0d09] --- projects/hip/CMakeLists.txt | 3 +- projects/hip/src/env.cpp | 91 ++++++++++++++++ projects/hip/src/env.h | 24 +++++ projects/hip/src/hip_hcc.cpp | 200 +++++++---------------------------- projects/hip/src/hip_hcc.h | 7 +- 5 files changed, 160 insertions(+), 165 deletions(-) create mode 100644 projects/hip/src/env.cpp create mode 100644 projects/hip/src/env.h diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index cbd2050025..53663e44b3 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -175,7 +175,8 @@ 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 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_hcc.cpp b/projects/hip/src/hip_hcc.cpp index c84b93b503..1de3a9e7d3 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 @@ -1037,166 +1038,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 (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 #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: @@ -295,9 +297,6 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); - - - class ihipException : public std::exception { public: From e95ebf93b1edda1479761aab310b59f46038b218 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 23 Jan 2017 22:33:21 -0600 Subject: [PATCH 036/104] Show dynamic shared mem usage not static. [ROCm/hip commit: 813c189b335207d6b6d84add0e96d5b1ff959810] --- projects/hip/src/hip_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index d6c50e82a9..5cce7cbb1b 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -298,7 +298,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, Kernel argument preparation. */ grid_launch_parm lp; - lp.dynamic_group_mem_bytes = f._groupSegmentSize; // TODO - this should be part of preLaunchKernel. + 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); From 0e2ccecc0b41e60ef08c14ae874b3b88f353e7f1 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 23 Jan 2017 22:34:09 -0600 Subject: [PATCH 037/104] Add debug tip to docs [ROCm/hip commit: 9dff0782a4e29285b041712ad1cc609d369292fe] --- projects/hip/docs/markdown/hip_profiling.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 772f762912..463c9c13b3 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -362,6 +362,12 @@ 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: From 90a02002c9c809793ab231da1d28c7cf8a50f47e Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 24 Jan 2017 22:30:36 -0600 Subject: [PATCH 038/104] Initial commit on hip_bugs markdown doc Change-Id: I5a6915337b8664cfed9eaee9443c6e4406348574 [ROCm/hip commit: f3da91de4e676e8a9411bebe74c530f35cc48257] --- projects/hip/docs/markdown/hip_bugs.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 projects/hip/docs/markdown/hip_bugs.md diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md new file mode 100644 index 0000000000..0bece74974 --- /dev/null +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -0,0 +1,24 @@ +# HIP Bugs + + + +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#error-undefined-reference) + + + +### 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 + From 716d972e53ed826aff118e64c3323e77885a2123 Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 24 Jan 2017 22:43:25 -0600 Subject: [PATCH 039/104] Add more hip_bug.md entry, regarding hang after hipLaunchKernel Change-Id: I5800cb627179ec0e913cd36d332fb8c2994ab71e [ROCm/hip commit: 95677edabbe4e1fca92ab762b451c2207bc6ff70] --- projects/hip/docs/markdown/hip_bugs.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 0bece74974..834cd9f8ce 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -2,7 +2,8 @@ -- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#error-undefined-reference) +- [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) @@ -22,3 +23,11 @@ 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. \ No newline at end of file From 43958812067b8d7d7dfc146c7d9269362d4f7158 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 25 Jan 2017 08:14:30 -0600 Subject: [PATCH 040/104] added device functions header to hip_runtime.h Change-Id: I635931e1fbe4b7f0f64f3a126c0f1badcd6d234b [ROCm/hip commit: d75d0596bfd466ef1aaf3404ec377513a3ce35ce] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 909b7f5680..822ee31f2b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -70,6 +70,7 @@ extern int HIP_TRACE_API; #endif #include #include +#include // TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define. #if defined (__KALMAR_ACCELERATOR__) && !defined (__HCC_ACCELERATOR__) From e129b09a6f8dc6db7c0eb7124c0f979812c99015 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 25 Jan 2017 21:50:52 -0600 Subject: [PATCH 041/104] Read HCC_OPT_FLUSH and optimize dispatch accordingly. If HCC is in this mode, we can use less aggressive flushes in some cases. [ROCm/hip commit: 1635b8f43fd024a891b008a473de6e09907c2459] --- projects/hip/src/hip_hcc.cpp | 5 +++++ projects/hip/src/hip_hcc.h | 3 +++ projects/hip/src/hip_module.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 1de3a9e7d3..7048947005 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -97,6 +97,8 @@ int HIP_COHERENT_HOST_ALLOC = 0; // USE_ HIP_SYNC_HOST_ALLOC int HIP_SYNC_HOST_ALLOC = 1; +int HCC_OPT_FLUSH = 0; + @@ -1204,6 +1206,9 @@ void HipReadEnv() READ_ENV_I(release, HIP_COHERENT_HOST_ALLOC, 0, "If set, all host memory will be allocated as fine-grained system memory. This allows threadfence_system to work but prevents host memory from being cached on GPU which may have performance impact."); + + READ_ENV_I(release, HCC_OPT_FLUSH, 0, "Note this flag also impact HCC. When set, use agent-scope flush rather than system-scope flush when possible."); + // Some flags have both compile-time and runtime flags - generate a warning if user enables the runtime flag but the compile-time flag is disabled. if (HIP_DB && !COMPILE_HIP_DB) { fprintf (stderr, "warning: env var HIP_DB=0x%x but COMPILE_HIP_DB=0. (perhaps enable COMPILE_HIP_DB in src code before compiling?)\n", HIP_DB); diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 276b93176e..9998c4ec0e 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -66,6 +66,9 @@ extern int HIP_COHERENT_HOST_ALLOC; // Chicken bits for disabling functionality to work around potential issues: extern int HIP_SYNC_HOST_ALLOC; +// TODO - remove when this is standard behavior. +extern int HCC_OPT_FLUSH; + // Class to assign a short TID to each new thread, for HIP debugging purposes. class TidInfo { diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 5cce7cbb1b..5eb3a6cf09 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -320,11 +320,17 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, 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); From bf3b6354ae0b44117cfcfb23bdd2127fa055c8ec Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 25 Jan 2017 21:53:17 -0600 Subject: [PATCH 042/104] Add HIP_FAIL_SOC. Fail sub-optimal-copies rather than perform them slowly. SOC occur on async copy of unpinned memory, or P2P copy between GPUs that are not peers. [ROCm/hip commit: 0409bf639c796666b119517a62fb07bae3c46e92] --- projects/hip/src/hip_hcc.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 7048947005..20ff1722e3 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -86,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. @@ -1198,6 +1199,7 @@ void HipReadEnv() READ_ENV_I(release, HIP_WAIT_MODE, 0, "Force synchronization mode. 1= force yield, 2=force spin, 0=defaults specified in application"); READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); + READ_ENV_I(release, HIP_FAIL_SOC, 0, "Fault on Sub-Optimal-Copy, rather than use a slower but functional implementation. Bit 0x1=Fail on async copy with unpinned memory. Bit 0x2=Fail peer copy rather than use staging buffer copy"); READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability"); @@ -1721,8 +1723,13 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, } } else { *forceUnpinnedCopy = true; - tprintf (DB_COPY, "P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", + tprintf (DB_COPY, "P2P: Copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + 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); + } } } @@ -1855,6 +1862,22 @@ 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); From 5eb33462b7ae9502ad137f44536fa1e2211344fe Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 26 Jan 2017 11:28:15 -0600 Subject: [PATCH 043/104] fix missing semicolon on NV path Change-Id: I3cfecb7bd534578a1f5a07ca9397092dcf01db07 [ROCm/hip commit: 84042156589635a17ddf2180809c18434f336e59] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3cd5667175..7b970da8df 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -88,7 +88,7 @@ typedef CUdeviceptr hipDeviceptr_t; typedef cudaChannelFormatKind hipChannelFormatKind; typedef cudaChannelFormatDesc hipChannelFormatDesc; typedef cudaTextureReadMode hipTextureReadMode; -typedef cudaArray hipArray +typedef cudaArray hipArray; // Flags that can be used with hipStreamCreateWithFlags #define hipStreamDefault cudaStreamDefault From 58721e8b7d1ea4c83f6e50509e723affa60015de Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 26 Jan 2017 12:30:52 -0600 Subject: [PATCH 044/104] more fix on hipmallocarray on NV path Change-Id: I890a36cab10c101f4a112bc4567f765b318d486c [ROCm/hip commit: 2e1a66103a8fbe2f89e2a5e3de8fe657f3cb6606] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 7b970da8df..11fde6aa10 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -220,7 +220,7 @@ inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int fla } inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_width, size_t height, unsigned int flags) { - return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); + return hipCUDAErrorTohipError(cudaMallocArray(array, desc, size_width, height, flags)); } inline static hipError_t hipFreeArray(hipArray* array) { @@ -334,15 +334,15 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* } 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, width, height, kind)); + return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, 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, 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(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, kind)); + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipDeviceSynchronize() { From 1d4c0862f116a756df6848d876e190b77f3c502a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 27 Jan 2017 14:32:08 +0530 Subject: [PATCH 045/104] hipMallocArray fixes for NV path Change-Id: I1ca43e6bc0cd405998888005c20dfb1ea57003d5 [ROCm/hip commit: 3e21d55c98c72b934500d977d7c64b4c84edce71] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 11fde6aa10..f5e7960d45 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -219,8 +219,8 @@ 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_width, size_t height, unsigned int flags) { - return hipCUDAErrorTohipError(cudaMallocArray(array, desc, size_width, height, 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) { @@ -334,7 +334,7 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* } 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, width, height, hipMemcpyKindToCudaMemcpyKind(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){ @@ -342,7 +342,7 @@ inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_ } inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); + return hipCUDAErrorTohipError(cudaMemcpyToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipDeviceSynchronize() { From a13cb5af4fe2c09d5675ffcd25359d26c8374341 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:41:42 -0600 Subject: [PATCH 046/104] fixed kernel only compilation for module api Change-Id: I567992fa9b87125318edba41fd82d2f7bc5504a1 [ROCm/hip commit: 6ba848a40fc6cc43e97382524041920a401b917c] --- projects/hip/bin/hccgenco.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 From ad08bdcfb0857564b0739597d174898f95533bb9 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:42:26 -0600 Subject: [PATCH 047/104] fixed threadfence ir Change-Id: Ia3afb54bdb50864e678d849608d72a3c321edba1 [ROCm/hip commit: f7ff199daab40ee83899bc34679c66e505f82a90] --- projects/hip/src/hip_ir.ll | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index c68e9879f2..5a14266086 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -2,12 +2,12 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64: target triple = "amdgcn--amdhsa" -define linkonce_odr spir_func void @__threadfence() #1 { +define void @__threadfence() #1 { fence syncscope(2) seq_cst ret void } -define linkonce_odr spir_func void @__threadfence_block() #1 { +define void @__threadfence_block() #1 { fence syncscope(3) seq_cst ret void } From 08a67a522da82943615e6f63fd452506012218db Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:51:48 -0600 Subject: [PATCH 048/104] fixed arch compiler flag Change-Id: I19f7a0ea513d6b8059f0c10cd0e7a5ead510e246 [ROCm/hip commit: b37422d30b4ecfcc7195cbea87ee6213edfebb1f] --- projects/hip/bin/hipcc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 004463bc2c..e43131501c 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -131,16 +131,16 @@ if ($HIP_PLATFORM eq "hcc") { # Handle ROCm target platform if ($ROCM_TARGET eq "fiji") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; } if ($ROCM_TARGET eq "carrizo") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:1"; + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; } if ($ROCM_TARGET eq "hawaii") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:7:0:1"; + $HIPLDFLAGS .= " --amdgpu-target=gfx701"; } if ($ROCM_TARGET eq "polaris") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; } # Add trace marker library: From 9d445cbf358f5847e3e6d6ad651b7a32f33ac187 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 09:20:14 -0600 Subject: [PATCH 049/104] changed device code tests to work not to work as one Change-Id: I0eec1eab19dda3b703bc3a0d778a6bbb2802a412 [ROCm/hip commit: 66dc2d42db6ede00096214591ce869e2c34551d1] --- .../src/deviceLib/hipDoublePrecisionIntrinsics.cpp | 13 +++++++++++++ .../src/deviceLib/hipDoublePrecisionMathDevice.cpp | 13 +++++++++++++ .../src/deviceLib/hipDoublePrecisionMathHost.cpp | 13 +++++++++++++ .../tests/src/deviceLib/hipFloatMathPrecise.cpp | 8 ++++++++ .../tests/src/deviceLib/hipIntegerIntrinsics.cpp | 14 ++++++++++++++ .../hip/tests/src/deviceLib/hipMathFunctions.cpp | 9 --------- .../src/deviceLib/hipSinglePrecisionIntrinsics.cpp | 13 +++++++++++++ .../src/deviceLib/hipSinglePrecisionMathDevice.cpp | 13 +++++++++++++ .../src/deviceLib/hipSinglePrecisionMathHost.cpp | 13 +++++++++++++ .../tests/src/deviceLib/hipTestDeviceSymbol.cpp | 8 ++++++++ .../hip/tests/src/deviceLib/hipThreadFence.cpp | 9 ++++++++- 11 files changed, 116 insertions(+), 10 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp index 1b087118b8..a3a302a3ef 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp @@ -19,6 +19,13 @@ 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" @@ -62,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 e5d57b4dce..df5dad3968 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp @@ -19,6 +19,13 @@ 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" @@ -124,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 af923da3aa..bfdf874c6d 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -19,6 +19,13 @@ 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" @@ -130,3 +137,9 @@ static void compileOnHost() { double_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp index 12f7875949..78fe47cfe8 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp @@ -19,6 +19,13 @@ 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" @@ -120,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 d712c5a93b..6bf13a0809 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -19,6 +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. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + + #include #include #include "test_common.h" @@ -57,3 +65,9 @@ __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 6737c6ee9d..3407748437 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp @@ -19,6 +19,12 @@ 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" @@ -78,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 4576faed93..53ccd2251f 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp @@ -19,6 +19,13 @@ 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" @@ -125,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 d48cea5ff6..933a51074f 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -19,6 +19,13 @@ 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" @@ -133,3 +140,9 @@ static void compileOnHost() { single_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 1158bf3f9d..f90ed38967 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -17,8 +17,15 @@ 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" #include #define NUM 1024 @@ -72,4 +79,5 @@ int main() for(unsigned i=0;i #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(); } From 76fa20bd8977493462e4b9c51325b9fd6c5b66e5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 17:38:43 -0600 Subject: [PATCH 050/104] removed host math functions from math_functions.h Change-Id: I90d8784e2d6b58c6fade9f0fa12c0db3ee417d3e [ROCm/hip commit: 60013396f6f4fa9e960e31141c83ffe2cd8d3371] --- .../include/hip/hcc_detail/math_functions.h | 42 ------------------- .../deviceLib/hipDoublePrecisionMathHost.cpp | 34 ++++++++------- .../deviceLib/hipSinglePrecisionMathHost.cpp | 37 ++++++++-------- .../hip/tests/src/deviceLib/hipTestDevice.cpp | 4 +- .../src/deviceLib/hipTestDeviceDouble.cpp | 4 +- 5 files changed, 41 insertions(+), 80 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 2755c896db..2cc4ef81bd 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -111,27 +111,6 @@ __device__ float y0f(float x); __device__ float y1f(float x); __device__ float ynf(int n, float x); -__host__ float cospif(float x); -__host__ float normcdff(float y); -__host__ float erfcinvf(float y); -__host__ float erfcxf(float x); -__host__ float erfinvf(float y); -__host__ float fdividef(float x, float y); -__host__ float norm3df(float a, float b, float c); -__host__ float normcdfinvf(float y); -__host__ float norm4df(float a, float b, float c, float d); -__host__ float rcbrtf(float x); -__host__ float rhypotf(float x, float y); -__host__ float rnorm3df(float a, float b, float c); -__host__ float rnormf(int dim, const float* a); -__host__ float rnorm4df(float a, float b, float c, float d); -__host__ void sincospif(float x, float *sptr, float *cptr); -__host__ int isfinite(float a); -__host__ float rsqrtf(float x); -__host__ float sinpif(float x); -__host__ int signbit(float a); - - __device__ double acos(double x); __device__ double acosh(double x); __device__ double asin(double x); @@ -220,27 +199,6 @@ __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); -__host__ double norm(int dim, const double *t); -__host__ double norm3d(double a, double b, double c); -__host__ double norm4d(double a, double b, double c, double d); -__host__ double normcdf(double y); -__host__ double normcdfinv(double y); -__host__ double rcbrt(double x); -__host__ double rhypot(double x, double y); -__host__ double rnorm(int dim, const double* t); -__host__ double rnorm3d(double a, double b, double c); -__host__ double rnorm4d(double a, double b, double c, double d); -__host__ void sincospi(double x, double *sptr, double *cptr); -__host__ double cospi(double x); -__host__ int isfinite(double x); -__host__ double rsqrt(double x); -__host__ int signbit(double a); -__host__ double sinpi(double x); - // ENDPARSER #ifdef HIP_FAST_MATH diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index bfdf874c6d..7f63d32e3d 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -27,8 +27,9 @@ THE SOFTWARE. */ #include -#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -50,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); @@ -93,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); 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); 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); diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 933a51074f..83bc740e9e 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -27,8 +27,9 @@ THE SOFTWARE. */ #include -#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -50,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); @@ -65,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); @@ -97,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); 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); diff --git a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp index 2c7488671b..570f3baaf0 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp @@ -164,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 f4e8ee20b8..5bdbbf1b8f 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp @@ -153,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; } } From afb38e15de69eb7317f69d1317418d391b765a04 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 1 Feb 2017 17:54:59 -0600 Subject: [PATCH 051/104] fixed symbol memcpy issue Change-Id: I89d7401be51d194bcbf771020ba66e3d3b6a18f8 [ROCm/hip commit: 2790e9a448255a219c369aad5c345a92ace04c57] --- projects/hip/src/hip_hcc.cpp | 23 +++++++++++++++++++ projects/hip/src/hip_hcc.h | 8 +++---- projects/hip/src/hip_memory.cpp | 22 +++++++++++------- .../src/deviceLib/hipTestDeviceSymbol.cpp | 8 +++++-- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 20ff1722e3..68bf74cd21 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1780,6 +1780,28 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const 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, const void* src, size_t sizeBytes, unsigned kind) +{ + hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); + hc::am_memtracker_add(dst, dstPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); +} void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) { @@ -1881,6 +1903,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes 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 9998c4ec0e..28ae6a2e8e 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -273,7 +273,7 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); API_TRACE(0, __VA_ARGS__); -// Like above, but will trace with DB_CMD. +// Like above, but will trace with DB_CMD. // Replace HIP_INIT_API with this call inside important APIs that launch work on the GPU: // kernel launches, copy commands, memory sets, etc. #define HIP_INIT_CMD_API(...) \ @@ -479,8 +479,6 @@ private: typedef ihipStreamCriticalBase_t ihipStreamCritical_t; typedef LockedAccessor LockedAccessor_StreamCrit_t; - - //--- // Internal stream structure. class ihipStream_t { @@ -494,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, const void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, const 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_memory.cpp b/projects/hip/src/hip_memory.cpp index d66c151266..df776aa707 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -449,17 +449,23 @@ 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, src, count + offset, kind); + // acc.memcpy_symbol(dst, (void*)src, count+offset); + } else { + return ihipLogStatus(hipErrorInvalidValue); + } return ihipLogStatus(hipSuccess); } @@ -479,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, src, count + offset, kind); } catch (ihipException ex) { e = ex._code; diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index f90ed38967..70fe794f67 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -47,7 +47,7 @@ __global__ void Assign(hipLaunchParm lp, int* Out) int main() { - int *A, *B, *Ad; + int *A, *Am, *B, *Ad; A = new int[NUM]; B = new int[NUM]; for(unsigned i=0;i Date: Fri, 3 Feb 2017 10:53:36 -0600 Subject: [PATCH 052/104] changed __global__ attribute 1. Moved around tests and added them to HIT Change-Id: I5d75280c42a5af852670ebabc7305ee56721ec7b [ROCm/hip commit: 5e3d63c0a38d5407e87182ada0360b3cc7f674bd] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 31 +++- .../hip/include/hip/hcc_detail/host_defines.h | 2 +- projects/hip/src/device_util.cpp | 14 +- .../device}/hipFuncDeviceSynchronize.cpp | 11 +- .../device}/hipFuncGetDevice.cpp | 4 +- .../device}/hipFuncSetDevice.cpp | 4 +- .../device}/hipFuncSetDeviceFlags.cpp | 16 +-- .../Negative/Device/hipDeviceGetAttribute.cpp | 0 .../Negative/Device/hipDeviceUtil.h | 0 .../Negative/Device/hipGetDevice.cpp | 0 .../Negative/Device/hipGetDeviceCount.cpp | 0 .../Device/hipGetDeviceProperties.cpp | 0 .../Negative/Device/hipSetDevice.cpp | 0 .../memory}/hipPerfMemcpy.cpp | 0 projects/hip/tests/src/buildHIPC.sh | 3 - .../src/{ => context}/hipDrvGetPCIBusId.cpp | 0 .../tests/src/{ => context}/hipDrvMemcpy.cpp | 0 .../tests/src/{ => deviceLib}/hipComplex.cpp | 0 .../src/{ => deviceLib}/hipDeviceMemcpy.cpp | 0 .../hip/tests/src/deviceLib/hipTestHalf.cpp | 132 ++++-------------- .../tests/src/{ => deviceLib}/hipTestHost.cpp | 0 projects/hip/tests/src/hipC.c | 30 ++++ projects/hip/tests/src/hipC.cpp | 27 +++- projects/hip/tests/src/hipCKernel.c | 1 + projects/hip/tests/src/hipChooseDevice.cpp | 17 --- .../hip/tests/src/hipPeerToPeer_simple.cpp | 36 ++--- projects/hip/tests/src/hipTestHalf.cpp | 56 -------- .../src/{ => kernel}/hipDynamicShared.cpp | 7 +- .../hipEmptyKernel.cpp} | 9 +- .../hip/tests/src/kernel/hipGridLaunch.cpp | 5 +- .../src/kernel/hipLanguageExtensions.cpp | 6 +- .../tests/src/{ => kernel}/hipLaunchParm.cpp | 4 +- .../hip/tests/src/kernel/hipTestConstant.cpp | 6 + .../tests/src/kernel/hipTestMallocKernel.cpp | 8 +- .../hip/tests/src/kernel/hipTestMemKernel.cpp | 28 ++++ .../hip/tests/src/kernel/launch_bounds.cpp | 10 +- .../src/runtimeApi/device/hipChooseDevice.cpp | 49 +++++++ .../device}/hipGetDeviceAttribute.cpp | 3 +- .../{ => runtimeApi/event}/hipEventRecord.cpp | 10 +- .../src/{ => runtimeApi/memory}/hipArray.cpp | 26 +++- .../memory}/hipHostGetFlags.cpp | 2 +- .../{ => runtimeApi/memory}/hipHostMalloc.cpp | 2 +- .../memory}/hipHostRegister.cpp | 2 +- .../src/runtimeApi/memory/hipMemcpyAsync2.cpp | 24 ++++ .../memory}/hipRandomMemcpyAsync.cpp | 2 +- .../memory}/hipTestMemcpyPin.cpp | 2 +- .../src/{ => runtimeApi/module}/hipModule.cpp | 0 .../module}/hipModuleUnload.cpp | 0 projects/hip/tests/src/sampleModule.cpp | 94 ------------- projects/hip/tests/src/vcpy_isa.co | Bin 9416 -> 0 bytes projects/hip/tests/src/vcpy_isa.cu | 6 - projects/hip/tests/src/vcpy_isa.ptx | 38 ----- 52 files changed, 316 insertions(+), 411 deletions(-) rename projects/hip/tests/src/{ => Functional/device}/hipFuncDeviceSynchronize.cpp (94%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncGetDevice.cpp (93%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncSetDevice.cpp (93%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncSetDeviceFlags.cpp (67%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipDeviceGetAttribute.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipDeviceUtil.h (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDevice.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDeviceCount.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDeviceProperties.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipSetDevice.cpp (100%) rename projects/hip/tests/src/{ => Performance/memory}/hipPerfMemcpy.cpp (100%) delete mode 100755 projects/hip/tests/src/buildHIPC.sh rename projects/hip/tests/src/{ => context}/hipDrvGetPCIBusId.cpp (100%) rename projects/hip/tests/src/{ => context}/hipDrvMemcpy.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipComplex.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipDeviceMemcpy.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipTestHost.cpp (100%) delete mode 100644 projects/hip/tests/src/hipChooseDevice.cpp delete mode 100644 projects/hip/tests/src/hipTestHalf.cpp rename projects/hip/tests/src/{ => kernel}/hipDynamicShared.cpp (97%) rename projects/hip/tests/src/{hipKernel.cpp => kernel/hipEmptyKernel.cpp} (89%) rename projects/hip/tests/src/{ => kernel}/hipLaunchParm.cpp (96%) create mode 100644 projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp rename projects/hip/tests/src/{ => runtimeApi/device}/hipGetDeviceAttribute.cpp (99%) rename projects/hip/tests/src/{ => runtimeApi/event}/hipEventRecord.cpp (96%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipArray.cpp (87%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostGetFlags.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostMalloc.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostRegister.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipRandomMemcpyAsync.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipTestMemcpyPin.cpp (97%) rename projects/hip/tests/src/{ => runtimeApi/module}/hipModule.cpp (100%) rename projects/hip/tests/src/{ => runtimeApi/module}/hipModuleUnload.cpp (100%) delete mode 100644 projects/hip/tests/src/sampleModule.cpp delete mode 100755 projects/hip/tests/src/vcpy_isa.co delete mode 100644 projects/hip/tests/src/vcpy_isa.cu delete mode 100644 projects/hip/tests/src/vcpy_isa.ptx diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 822ee31f2b..aa6fe06337 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 @@ -345,14 +345,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/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/src/device_util.cpp b/projects/hip/src/device_util.cpp index d80d9e7ef5..fb207e3996 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -99,7 +99,7 @@ __device__ void* __hip_hc_free(void *ptr) // 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; @@ -110,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; @@ -120,16 +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); -} - __device__ float __hip_erfinvf(float x){ float ret; int sign; 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/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/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 12b7e2e270..7455037923 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -1,16 +1,13 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. - +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 @@ -20,113 +17,40 @@ 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" -#include "hip/hip_runtime.h" +#include +#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 DSIZE 4 +#define SCF 0.5f +#define nTPB 256 +__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){ -__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]); - Out[10] = hceil(In1[10]); - Out[11] = hcos(In1[11]); - Out[12] = hexp(In1[12]); - Out[13] = hexp10(In1[13]); - Out[14] = hexp2(In1[14]); - Out[15] = hfloor(In1[15]); - Out[16] = hlog(In1[16]); - Out[17] = hlog10(In1[17]); - Out[18] = hlog2(In1[18]); -// Out[19] = hrcp(In1[19]); - Out[20] = hrint(In1[20]); - Out[21] = hrsqrt(In1[21]); - Out[22] = hsin(In1[22]); - Out[23] = hsqrt(In1[23]); - Out[24] = htrunc(In1[24]); -} + int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x; + if (idx < dsize){ + __half scf = __float2half(SCF); + __half kin = __float2half(din[idx]); + __half kout; -__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]); - Out[10] = h2ceil(In1[10]); - Out[11] = h2cos(In1[11]); - Out[12] = h2exp(In1[12]); - Out[13] = h2exp10(In1[13]); - Out[14] = h2exp2(In1[14]); - Out[15] = h2floor(In1[15]); - Out[16] = h2log(In1[16]); - Out[17] = h2log10(In1[17]); - Out[18] = h2log2(In1[18]); - Out[19] = h2rcp(In1[19]); -// Out[20] = h2rint(In1[20]); - Out[21] = h2rsqrt(In1[21]); - Out[22] = h2sin(In1[22]); - Out[23] = h2sqrt(In1[23]); - Out[24] = h2trunc(In1[24]); -} + kout = __hmul(kin, scf); -__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]); -} - -__global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* Out) { - Out[0] = __heq2(In1[0], In2[0]); - Out[1] = __hge2(In1[1], In2[1]); - Out[2] = __hgt2(In1[2], In2[2]); - Out[4] = __hisnan2(In1[4]); - Out[5] = __hle2(In1[5], In2[5]); - Out[6] = __hlt2(In1[6], In2[6]); - Out[7] = __hne2(In1[7], In2[7]); +// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf)); + dout[idx] = __half2float(kout); + } } int main(){ - passed(); + + 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/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/hipC.c b/projects/hip/tests/src/hipC.c index 50177ac6c2..cdecc2cf9d 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 + * 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/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/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..e519a1c2a8 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 @@ -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..2d637e3f1a 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -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 #include #include diff --git a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp index 826f6164c3..bd0c17d898 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 + * 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 100% rename from projects/hip/tests/src/hipModule.cpp rename to projects/hip/tests/src/runtimeApi/module/hipModule.cpp 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/sampleModule.cpp b/projects/hip/tests/src/sampleModule.cpp deleted file mode 100644 index 7ee9147e45..0000000000 --- a/projects/hip/tests/src/sampleModule.cpp +++ /dev/null @@ -1,94 +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 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. -*/ - -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" -#include -#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;ig>F%yYE55 zFR+Z2LV0lu%{!G%XF?)RhVeIfnBT*1N!!dXbRFkp)4`B#*z|z&%=euCq(b_=EKEDT zz>CaF9(*_bPPfzVj~XvW<9<8ER8a<$0cAiLPzIC%Wk4BF29yD1KpFV&89@E#kyNgQ z83p0=6sxpK`wY#|xhV(AaRC=>g`WC@AUMsEHtqK`6rYL*($72cuM)levddNRE)@@i zjUC$m#HSQDJioZ@m5ODe`XSfMfzMdMr)|$GmN!hy#-VSD{Wl!1O&L%IlmTTx8Bhk4 z0cAiLPzIC%Wk4DD_ZUE7{@EP_%)238a?;$jv%Vyk#oSQ!FIqFb!~cPU1cyUNSuC}* zxU1{6^v+rEEBx?@gTVv-qX2j3z&QSP{jua8(>dpwarivSkc~`}j9K^I6t%a8ldSAXse6%TqXiiV@4Ly;XoG~OI0y+Nlj=p=DFPU6(j8V#TIo*$VL>*el~ z_$ft`?j#vo%}UB%t~Y8=?pN3E-pma81ggwe*3K;xVLc(QyS{~6i3QhK=Q+k?t&xxQ zghZU=N;AhD8F`*{=^OdjFOb+T9AX;!fqjt`!LT3kzXBxwTR?n%ODwxw8G~uzv}`&P ze#{@|R@c~Haxq!a46Rkmf~;fyfLB?`&q;jmLwQ?ntY+W&*foapm_&XE<^5~R$3Eha zJSJIxn&0ABtexbceGIL3#{mm0nzB6eyp2}&B`CF*u)FJ G$^Qui; - .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; -} - - From 82e6141cfd711d44a53c8a6b076b0b65159cae7f Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 6 Feb 2017 13:00:50 +0530 Subject: [PATCH 053/104] Disable broken test: hipC Change-Id: I061aa125bbdc9f14bc870266ab0735593c861903 [ROCm/hip commit: 939909e96cdd1f852c228c784e23335c789d77d2] --- projects/hip/tests/src/hipC.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/hipC.c b/projects/hip/tests/src/hipC.c index cdecc2cf9d..644df6c98f 100644 --- a/projects/hip/tests/src/hipC.c +++ b/projects/hip/tests/src/hipC.c @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ From 3d04971de32fad25a1f383c80cb6726b0578ec4a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 7 Feb 2017 15:03:46 +0530 Subject: [PATCH 054/104] Command scripts for latency measurements Change-Id: I8c28765a09fb0358447367939de524b12699a317 [ROCm/hip commit: 55df1b6ff2e4c2fa81ccab3fd14ee6437f341b5d] --- .../hipCommander/perf/scripts/latency_2_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_d2h_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_2_d2h_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_h2d_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_2_h2d_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_2_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_2_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_sync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2d2h_wosync.hcm | 10 ++++++++++ .../1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2h2d_kernel_wosync.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2h2d_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2kernels.hcm | 10 ++++++++++ .../perf/scripts/latency_2kernels_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_d2h_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_3_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_3_d2h_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_h2d_d2h.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_3_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_3_h2d_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_3_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_3_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_sync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3d2h_wosync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3h2d_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3kernels.hcm | 10 ++++++++++ .../perf/scripts/latency_3kernels_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_4kernels.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_5kernels.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_6kernels.hcm | 10 ++++++++++ .../1_Utils/hipCommander/perf/scripts/latency_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_d2h_sync_kernel.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_h2d_10.hcm | 2 ++ .../hipCommander/perf/scripts/latency_h2d_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_d2h_wosync.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_wosync.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_sync_kernel_sync.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel.hcm | 10 ++++++++++ .../perf/scripts/latency_kernel_barrier.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_streamcreate.hcm | 2 ++ .../1_Utils/hipCommander/perf/scripts/latency_sync.hcm | 9 +++++++++ 66 files changed, 596 insertions(+) create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm 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); From 172161a5b502754c3000a82ba6fd79f03919033e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Feb 2017 11:09:54 -0600 Subject: [PATCH 055/104] fixed vector types for c Change-Id: I2330e976060f9a038929cd51be07ae2ee98e81ce [ROCm/hip commit: 3664e8784f7eb9bb5191c356f36f52bff0d50dc6] --- .../include/hip/hcc_detail/hip_vector_types.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 3e3acb8f29..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; \ From e0f59128990cb93c7d42b61782bbd1b371d83578 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Feb 2017 13:15:36 -0600 Subject: [PATCH 056/104] Fixed HIP for C runtime 1. fixed constant memory test 2. added runtime gcc/g++ test 3. added fix for runtime with gcc/g++ Change-Id: Ie14dad6633411b188bdeea044e140b6d5beabe16 [ROCm/hip commit: 05c8aa1cf536094b5908309988ef8ba8577f4983] --- .../hip/hcc_detail/channel_descriptor.h | 18 +++++++++++++----- .../include/hip/hcc_detail/hip_runtime_api.h | 10 +++++++--- .../hip/include/hip/hcc_detail/hip_texture.h | 1 + .../hip/include/hip/hcc_detail/texture_types.h | 6 +++--- projects/hip/tests/src/g++/hipMalloc.cpp | 8 ++++++++ projects/hip/tests/src/gcc/hipMalloc.c | 8 ++++++++ .../hip/tests/src/kernel/hipTestConstant.cpp | 2 ++ 7 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 projects/hip/tests/src/g++/hipMalloc.cpp create mode 100644 projects/hip/tests/src/gcc/hipMalloc.c diff --git a/projects/hip/include/hip/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h index 91d48af4cf..85689438e2 100644 --- a/projects/hip/include/hip/hcc_detail/channel_descriptor.h +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -26,12 +26,9 @@ THE SOFTWARE. #include #include -hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); +#ifdef __cplusplus -template -static inline hipChannelFormatDesc hipCreateChannelDesc() { - return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); -} +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); static inline hipChannelFormatDesc hipCreateChannelDescHalf() { int e = (int)sizeof(unsigned short) * 8; @@ -49,6 +46,11 @@ static inline hipChannelFormatDesc hipCreateChannelDescHalf2() return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); } +template +static inline hipChannelFormatDesc hipCreateChannelDesc() { + return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); +} + template<> inline hipChannelFormatDesc hipCreateChannelDesc() { @@ -371,4 +373,10 @@ inline hipChannelFormatDesc hipCreateChannelDesc() 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/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index f9ab03901a..4e5390a968 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -180,7 +180,7 @@ typedef enum hipMemcpyKind { typedef struct { unsigned int width; unsigned int height; - hipChannelFormatKind f; + enum hipChannelFormatKind f; void* data; //FIXME: generalize this } hipArray; @@ -371,7 +371,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); /** @@ -1254,9 +1254,13 @@ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; * * @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. * diff --git a/projects/hip/include/hip/hcc_detail/hip_texture.h b/projects/hip/include/hip/hcc_detail/hip_texture.h index bd44206be4..d60f66ddc2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_texture.h +++ b/projects/hip/include/hip/hcc_detail/hip_texture.h @@ -31,6 +31,7 @@ THE SOFTWARE. */ #include +#include #include #include //#include diff --git a/projects/hip/include/hip/hcc_detail/texture_types.h b/projects/hip/include/hip/hcc_detail/texture_types.h index d9221dc009..107b5d26c1 100644 --- a/projects/hip/include/hip/hcc_detail/texture_types.h +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -34,9 +34,9 @@ enum hipTextureFilterMode }; struct textureReference { - hipTextureFilterMode filterMode; - bool normalized; - hipChannelFormatDesc channelDesc; + enum hipTextureFilterMode filterMode; + unsigned normalized; + struct hipChannelFormatDesc channelDesc; }; #endif 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/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index 2d637e3f1a..e4d187b4d6 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include #include #include +#include "test_common.h" #define HIP_ASSERT(status) \ assert(status == hipSuccess) @@ -62,4 +63,5 @@ int main() { assert(A[i] == B[i]); } + passed(); } From 655045d722f8f7dee482b43023db9059ceb35bd4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 8 Feb 2017 19:43:32 +0300 Subject: [PATCH 057/104] [HIPIFY] Readme.md update. + Launching example. + Delimiter "--" is strongly recommended. + "-x cuda" option is mentioned as well. [ROCm/hip commit: 841510481ed3b85887d7fad359ba9cc31d0823dc] --- projects/hip/hipify-clang/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 6e58f719b7..3996a63b8c 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -47,6 +47,14 @@ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/c 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 delimeter) from clang options (after the delimeter). It is strongly recomended to always specify the delimeter, 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 From dbd5346cffa674428e91d25f9d208dc1e2d431f4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 8 Feb 2017 19:50:05 +0300 Subject: [PATCH 058/104] [HIPIFY] Readme.md update. [ROCm/hip commit: 9ba480037ae8ed666e3deaa8bb9255e19fd6d072] --- projects/hip/hipify-clang/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 3996a63b8c..850dfb3ffa 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -47,12 +47,14 @@ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/c 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 delimeter) from clang options (after the delimeter). It is strongly recomended to always specify the delimeter, 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. + +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). From 82c0dcb03fcd2fc329342d823c65bac942661d8b Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 12:04:05 -0600 Subject: [PATCH 059/104] Fixed Hawaii link issues 1. Split hip_ir.ll to hip_hc.ll and hip_hc_gfx803.ll a. hip_hc.ll contains arch generic ir implementations b. hip_hc_gfx803.ll contains gfx803 (fiji, polaris) specific ir 2. HIPCC can now parse --amdgpu-target=*. a. Usage: hipcc --amdgpu-target=gfx803 --amdgpu-target=gfx701 b. TODO: Convert to --amdgpu-target=gfx803,gfx701 3. With LLC in HCC able to generate native f16 isa, removed inline half asm math ops 4. Fixed threadfence and threadfence_block to use functions in rocdl Change-Id: Ic9a9e3e04139b0d75d2c2a263c030ca77adc1019 [ROCm/hip commit: 01b66dd998a56f5c88764bb18d438f4b731af6ac] --- projects/hip/CMakeLists.txt | 2 +- projects/hip/bin/hipcc | 47 ++++++++-- .../hip/include/hip/hcc_detail/hip_fp16.h | 73 +++------------ .../hip/include/hip/hcc_detail/hip_runtime.h | 12 ++- projects/hip/src/hip_fp16.cpp | 41 +++++++++ projects/hip/src/hip_hc.ll | 30 +++++++ .../hip/src/{hip_ir.ll => hip_hc_gfx803.ll} | 89 ------------------- 7 files changed, 134 insertions(+), 160 deletions(-) create mode 100644 projects/hip/src/hip_hc.ll rename projects/hip/src/{hip_ir.ll => hip_hc_gfx803.ll} (62%) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 53663e44b3..9c469afbc1 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -218,7 +218,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) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index e43131501c..777a1b3f9d 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"; @@ -129,18 +134,25 @@ if ($HIP_PLATFORM eq "hcc") { } $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + # Handle ROCm target platform - if ($ROCM_TARGET eq "fiji") { - $HIPLDFLAGS .= " --amdgpu-target=gfx803"; - } - if ($ROCM_TARGET eq "carrizo") { - $HIPLDFLAGS .= " --amdgpu-target=gfx801"; - } - if ($ROCM_TARGET eq "hawaii") { + if ($target_gfx701 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx701"; } - if ($ROCM_TARGET eq "polaris") { + if ($target_gfx801 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + } + if ($target_gfx802 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + } + if ($target_gfx803 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_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"; } # Add trace marker library: @@ -222,7 +234,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,6 +274,22 @@ 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++"; diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 67d1fe4e06..2c7c23440c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -39,16 +39,16 @@ typedef struct __attribute__((aligned(4))){ /* Half Arithmetic Functions */ -__device__ static __half __hadd(const __half a, const __half b); -__device__ static __half __hadd_sat(__half a, __half b); -__device__ static __half __hfma(__half a, __half b, __half c); -__device__ static __half __hfma_sat(__half a, __half b, __half c); -__device__ static __half __hmul(__half a, __half b); -__device__ static __half __hmul_sat(__half a, __half b); -__device__ static __half __hneg(__half a); -__device__ static __half __hsub(__half a, __half b); -__device__ static __half __hsub_sat(__half a, __half b); -__device__ static __half hdiv(__half a, __half b); +__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); /* Half2 Arithmetic Functions @@ -211,11 +211,6 @@ __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" __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); - 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); @@ -244,46 +239,6 @@ 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); -__device__ static inline __half __hadd(const __half a, const __half b) { - return __hip_hc_ir_hadd_half(a, b); -} - -__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; -} - /* Half2 Arithmetic Functions */ @@ -360,11 +315,11 @@ __device__ static inline __half hcos(const __half h) { } __device__ static inline __half hexp(const __half h) { - return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 1.442694)); + return __hip_hc_ir_hexp2_half(__hmul(h, 1.442694)); } __device__ static inline __half hexp10(const __half h) { - return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 3.3219281)); + return __hip_hc_ir_hexp2_half(__hmul(h, 3.3219281)); } __device__ static inline __half hexp2(const __half h) { @@ -376,11 +331,11 @@ __device__ static inline __half hfloor(const __half h) { } __device__ static inline __half hlog(const __half h) { - return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.693147); + return __hmul(__hip_hc_ir_hlog2_half(h), 0.693147); } __device__ static inline __half hlog10(const __half h) { - return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.301029); + return __hmul(__hip_hc_ir_hlog2_half(h), 0.301029); } __device__ static inline __half hlog2(const __half h) { diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index aa6fe06337..98c3ada969 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -277,6 +277,10 @@ __device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); * 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. * @@ -287,7 +291,9 @@ __device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); * @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. @@ -299,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. diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index ac79ddba08..b306a9d3de 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -32,6 +32,47 @@ struct hipHalfHolder{ #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 */ 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_ir.ll b/projects/hip/src/hip_hc_gfx803.ll similarity index 62% rename from projects/hip/src/hip_ir.ll rename to projects/hip/src/hip_hc_gfx803.ll index 5a14266086..0080fc7d81 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_hc_gfx803.ll @@ -2,65 +2,6 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64: target triple = "amdgcn--amdhsa" -define void @__threadfence() #1 { - fence syncscope(2) seq_cst - ret void -} - -define void @__threadfence_block() #1 { - fence syncscope(3) seq_cst - ret void -} - -; 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) @@ -146,34 +87,4 @@ define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { ret i32 %1 } -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 -} - -define i32 @__hip_hc_ir_sadu8_int(i32 %a, i32 %b, i32 %c) #1 { - %1 = tail call i32 asm sideeffect "v_sad_u8 $0, $1, $2 $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) - ret i32 %1 -} - attributes #1 = { alwaysinline nounwind } From c692cd5d4ada4db9d697babdf9146ec4b0f61d75 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 12:19:06 -0600 Subject: [PATCH 060/104] include arch specific ir on fallback path Change-Id: Ib04996aae2c21eb73ef2a9f6305915e0caccd704 [ROCm/hip commit: 27d2fc99ca083c44c312b7f05d11ae38ffa75495] --- projects/hip/bin/hipcc | 1 + .../hip/tests/src/deviceLib/hipTestHalf.cpp | 36 ++++--------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 777a1b3f9d..7df674f57b 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -153,6 +153,7 @@ if ($HIP_PLATFORM eq "hcc") { 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{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } # Add trace marker library: diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 7455037923..2284148bb5 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.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,40 +17,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#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); - } +__global__ void halfMath(hipLaunchParm lp, half *A, half *B, half *C) { + int tx = hipThreadIdx_x; + __half a = A[tx]; + } 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; } From 8794954411d5933e67013b0c20a3c183973659ee Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 14:06:01 -0600 Subject: [PATCH 061/104] fixed hipcc for new compiler flags Change-Id: I49ec059be20ff26b7482c84d91ab7a43826c6a8d [ROCm/hip commit: 55d92833fb771d724cc81c6a7eabd184cd0ac38f] --- projects/hip/bin/hipcc | 48 ++++++++++--------- .../hip/tests/src/deviceLib/hipTestHalf.cpp | 43 ++++++++++++++++- 2 files changed, 67 insertions(+), 24 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7df674f57b..2a16b5702a 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -134,28 +134,6 @@ if ($HIP_PLATFORM eq "hcc") { } $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; - $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; - - # Handle ROCm target platform - if ($target_gfx701 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx701"; - } - if ($target_gfx801 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx801"; - } - if ($target_gfx802 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx802"; - } - if ($target_gfx803 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx803"; - $ENV{HIP_HC_IR_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{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; - } - # 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) { @@ -352,6 +330,32 @@ 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"; + } + if ($target_gfx801 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + } + if ($target_gfx802 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + } + if ($target_gfx803 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_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{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + +} + if ($hasC and $HIP_PLATFORM eq 'nvcc') { $HIPCXXFLAGS .= " -x cu"; } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 2284148bb5..997c445a10 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -21,12 +21,51 @@ THE SOFTWARE. #include #include "hip/hip_runtime_api.h" -__global__ void halfMath(hipLaunchParm lp, half *A, half *B, half *C) { +#define LEN 64 +#define HALF_SIZE 64*sizeof(__half) +#define HALF2_SIZE 64*sizeof(__half2) + +__global__ void __halfMath(hipLaunchParm lp, __half *A, __half *B, __half *C) { int tx = hipThreadIdx_x; __half a = A[tx]; - + __half b = B[tx]; + __half c = C[tx]; + c = __hadd(a, c); + c = __hadd_sat(b, c); + c = __hfma(a, c, b); + c = __hfma_sat(b, c, a); + c = __hsub(a, c); + c = __hsub_sat(b, c); + c = __hmul(a, c); + c = __hmul_sat(b, c); + c = hdiv(a, c); +} + +__global__ void __half2Math(hipLaunchParm lp, __half2 *A, __half2 *B, __half2 *C) { + int tx = hipThreadIdx_x; + __half2 a = A[tx]; + __half2 b = B[tx]; + __half2 c = C[tx]; + c = __hadd2(a, c); + c = __hadd2_sat(b, c); + c = __hfma2(a, c, b); + c = __hfma2_sat(b, c, a); + c = __hsub2(a, c); + c = __hsub2_sat(b, c); + c = __hmul2(a, c); + c = __hmul2_sat(b, c); } 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); } From 036a95a4db28465d8b127085f0f4545084b087b2 Mon Sep 17 00:00:00 2001 From: pensun Date: Wed, 8 Feb 2017 16:19:28 -0600 Subject: [PATCH 062/104] Add pseudo code example for hip_bugs.md Change-Id: Ia2af8e6165faeb3fbb81428e20d4dc5b19b2fa9e [ROCm/hip commit: 79978182f9f858ce5a9fc94c0d9d52ec7c8833ce] --- projects/hip/docs/markdown/hip_bugs.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 834cd9f8ce..3274ed5b5c 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -30,4 +30,17 @@ 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. \ No newline at end of file +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 From d48f7e93ccd1f25aa07ef996fcded89600c96e0d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 19:45:32 -0600 Subject: [PATCH 063/104] added architecture specific macros 1. Added __HIP_ARCH_GFXNUM__ 2. Usage, -D__HIP_ARCH_GFX803__=1 Change-Id: I68b3a85d62cfab3a45d2b7a70cb3518ab2565236 [ROCm/hip commit: 9a1989193acf5199dcd4ac7a8259067a2f1b271e] --- projects/hip/bin/hipcc | 8 ++++++-- projects/hip/tests/src/deviceLib/hipTestHalf.cpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 2a16b5702a..944fc04135 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -266,7 +266,7 @@ foreach $arg (@ARGV) $target_gfx802 = 1; } if($arg eq '--amdgpu-target=gfx803') - { + { $target_gfx803 = 1; } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) @@ -337,18 +337,22 @@ if($HIP_PLATFORM eq "hcc"){ # 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{HIP_HC_IR_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) + 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{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 997c445a10..94a3882eea 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -25,6 +25,8 @@ THE SOFTWARE. #define HALF_SIZE 64*sizeof(__half) #define HALF2_SIZE 64*sizeof(__half2) +#if __HIP_ARCH_GFX803__ > 0 + __global__ void __halfMath(hipLaunchParm lp, __half *A, __half *B, __half *C) { int tx = hipThreadIdx_x; __half a = A[tx]; @@ -56,6 +58,8 @@ __global__ void __half2Math(hipLaunchParm lp, __half2 *A, __half2 *B, __half2 *C c = __hmul2_sat(b, c); } +#endif + int main(){ __half *A, *B, *C; hipMalloc(&A, HALF_SIZE); From 4e9f1e8a66398209c033c5b0f10144cdbd5ebe3d Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 14:38:39 +0530 Subject: [PATCH 064/104] Fix arch specific hcc extra libs env var Change-Id: I7429da2f1cb98750d6a9601e7e5bde844a098487 [ROCm/hip commit: d14b239dd3496f44d8e70da5d83e57e17b68690f] --- projects/hip/bin/hipcc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 944fc04135..2b84041e50 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -350,12 +350,12 @@ if($HIP_PLATFORM eq "hcc"){ if ($target_gfx803 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx803"; $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX803__=1 "; - $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + $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{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } } From 4c505556537702aa20cdd796db9f36f149b0df28 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 14:48:22 +0530 Subject: [PATCH 065/104] Disable failing directed tests - hipTestDeviceSymbol - hipTestConstant - hipTestMallocKernel Change-Id: Ibfe9fc0b8a59882f1de64b42e18777a7bd56ee97 [ROCm/hip commit: 5754d641e06b000000de288b75721b223d2316c1] --- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/kernel/hipTestConstant.cpp | 2 +- projects/hip/tests/src/kernel/hipTestMallocKernel.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 70fe794f67..ed4d3902c5 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index e4d187b4d6..6d630f97ff 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp index bd0c17d898..9dd8b053a5 100644 --- a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ From 35504c5348a9ccc627d3fe30292eb80da245328b Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 20:28:28 +0530 Subject: [PATCH 066/104] Update hip_hcc packaging script Change-Id: I2dc96545c472942bcf2bc8a2e88735f3ba26d1e1 [ROCm/hip commit: 14442b3ef7484aaa08d3fb0da0621f08c4c4770d] --- projects/hip/packaging/hip_hcc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 76f30e96e830cc4e28988e53880361d81ab3dcdb Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 17:22:55 -0600 Subject: [PATCH 067/104] fixed hipFunction memory management Change-Id: I7ebb323419bcd220ebd6466a8eb38e7bfdb1520a [ROCm/hip commit: 6fd3daed30a304f46f0a0822e968a0d7d52e36fe] --- .../include/hip/hcc_detail/hip_runtime_api.h | 10 +--- projects/hip/src/hip_module.cpp | 44 +++++++++++++----- projects/hip/src/trace_helper.h | 11 ----- .../tests/src/runtimeApi/module/hipModule.cpp | 24 +++++++--- .../src/runtimeApi/module/vcpy_kernel.code | Bin 0 -> 18811 bytes .../src/runtimeApi/module/vcpy_kernel.cpp | 30 ++++++++++++ 6 files changed, 82 insertions(+), 37 deletions(-) create mode 100755 projects/hip/tests/src/runtimeApi/module/vcpy_kernel.code create mode 100644 projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp 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 4e5390a968..7abfffcc22 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include +#include #include #include @@ -72,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; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 5eb3a6cf09..63a6bffa94 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -35,6 +35,25 @@ 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; + char _name[64]; // TODO - review for performance cost. Name is just used for debug. +}; + +std::list hipFuncTracker; + +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;\ @@ -217,6 +236,7 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char ret = hipErrorInvalidContext; }else{ + 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 +250,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)); + strncpy(sym->_name, name, sizeof(sym->_name)); + *func = sym; + hipFuncTracker.push_back(*func); } return ihipLogStatus(ret); } @@ -297,9 +319,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, /* Kernel argument preparation. */ - grid_launch_parm lp; + 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); + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name); hsa_kernel_dispatch_packet_t aql; @@ -315,9 +337,9 @@ 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); // TODO - honor queue setting for execute_in_order @@ -333,7 +355,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); - ihipPostLaunchKernel(f._name, hStream, lp); + ihipPostLaunchKernel(f->_name, hStream, lp); } return ihipLogStatus(ret); @@ -355,7 +377,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/trace_helper.h b/projects/hip/src/trace_helper.h index f58f81fbff..3bf2857c3a 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -72,17 +72,6 @@ inline std::string ToString(hipEvent_t v) return ss.str(); }; -// hipEvent_t specialization. TODO - maybe add an event ID for debug? -template <> -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/runtimeApi/module/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp index d9193cd87f..d7552ee1e6 100644 --- a/projects/hip/tests/src/runtimeApi/module/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){ @@ -59,11 +61,11 @@ int main(){ hipStream_t stream; HIPCHECK(hipStreamCreate(&stream)); void *args[2] = {&Ad, &Bd}; + std::cout<argBuffer(2); - memcpy(&argBuffer[0], &Ad, sizeof(void*)); - memcpy(&argBuffer[1], &Bd, sizeof(void*)); + std::vectorargBuffer(5); + memcpy(&argBuffer[3], &Ad, sizeof(void*)); + memcpy(&argBuffer[4], &Bd, sizeof(void*)); size_t size = argBuffer.size()*sizeof(void*); @@ -73,7 +75,7 @@ int main(){ 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)); @@ -82,7 +84,15 @@ int main(){ 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; + } + std::cout<<"Starting sleep"<!|TyJEXSpxJp$K3RyD-7nQWZaI>aj^(hg-HsJefl%aEHtUM6q;d-2|D+t< z-^}lh$?vZyD)z})0h1JFVvj&M-kwOmR)KBt_OQbkeDYJFlO)@t#6DyDqm$#j7{(Fb z0srU^h{xGRo)6S62Kd40$K1S!p#F^_@4&!7?`9GeMzZ{G=gyt#p|LS_=CP@xhbIrH2WDoD%siP-tM_$O!%-`> zx&<02^;(n1%qN?B`qe$@Ro9SNbq(27*D$o|8gi?yA;0Px3ahI@eM&vun@lEq(brZA z=%d?lCJ^($v=~4p;9C*j<(5GQNZGtc<4#&&l{hgx}@j{h(u*CH!tz9~bxu!c`Zi{O1Y3SH`~}e5;G^67^gl z{0o$x#5{8tFy?&4Wd&o)r;9|O)SxA7QbHwcN{!FfwG!_gbzDjpkL zzX`5ec#JW0rd!~jrbPiuLNv|iH%thchxxMy($MX2j=UNEdC-qfrPBJri6i?*Cv<&E zPi1rZ@l>j6)$1+&`IcQbQ@J_2X6kigzFDs7ZNqL%S02@Ly#l(^vQxvlUOsu!XtZ_5 zhHDFFxC1pFrXQ|MSD3C>Yi+$+)@!z2O_!}&U58oJ54So2sCBZP4uC85R?7~+>#ez< z>~^^wklF4$XFCCSr`8NYgEKoeSYdf~!!!drQfU|gXk)$}fOh6f%TdglUDg_))!H(2 zJ~%VNLAg7I$*Um0h-74e$O4fCA`3(o_zzlu);v9YH3gsc2w0)7J?txX9?~}R71dHE zv3%yhCifG1H!&WM2Q8(#>DM!&u*4!RNk3x>tbE`7T9wo8R zvoTR%Z2BUsAL9yOF@-Jk^dt&xo~M0L!NnkZ8S<~MKy+U#|7->RaV<_E;ag?@xA|8V zvETcdvWOIN&XHS1S%41$@R4Huafz50`Y#M7`Y`)I zH2$wL{@H60|MK7mEqMInyEh7n?i(~0Sx?V@SpO~JT;^Q|C`x>Rv5P;mST8IQ!u34( zcg8<{YqS*B6aQY`SuDQqvJ&6NwrzmdzTx7X*jX$77}rq_+M%K$Jify{9jfQ zQvQp;e=(Z>iF=g6{Cj8o_4xjW zp8M==W#RH$@a|{Z26$%~&S$=t&9$2UL&N_^!2gF4|6U)F;~^jauK@q&BK~F0y;{im ze-rqBBjVr7xEv2T|1SgoXCwY)&b?a5`9B5xzZmiFWn7Mjoc}Yx|3bvS%(+(!IsYF3 z|L;fqdl{GGA?N=z@c&Z8zs$K;3pxMq0RQLzKm2={jpC67A`3(oh%69UAhN*!!vgff z{LjS~IJCb~Y}4%ilK&8H!h}GZa<_<$l=QvNCsdJ}ZRv`exyyBNxGr$l%~y z&8g0plI2!oaKPYL2xU?Rm!<D;`Q&W+`P^rcuhK$^~;clh0MnHa=pk=Y_%mj{1dIHrM@ z*L+#2{C&Oxq>{va)ZM;&>Uee3Ri5@>7^QLqqfWLb4CSS9SNlmMqL1JlL-$Yo zd`7r%OltRA!hPo>{6M(xe1zW!_nnV$g>c{b2wUO)xE*}wBj7m(99N+r1UesKAK~}P z_))@r=Oa8rxbJ*~vxNK3NBEd<;qY{x!qePX$&UR1 literal 0 HcmV?d00001 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]; +} + From 21d09049cbff617b552aa2b65b2d1d2c1c10d906 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 18:07:48 -0600 Subject: [PATCH 068/104] added new dynamic shared mem test Change-Id: Ic2a12fc9bc5b67e85f1e6c6008f10c7c66388377 [ROCm/hip commit: 2a064cfcc59cd9f164c6e295c8ab76fcf27ea6ce] --- .../tests/src/kernel/hipDynamicShared2.cpp | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 projects/hip/tests/src/kernel/hipDynamicShared2.cpp diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp new file mode 100644 index 0000000000..f4dcf0d1e8 --- /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); + } + passed(); +} From e48175e40495ae3b9b943d5e4cc20de356e0ed8d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 18:17:42 -0600 Subject: [PATCH 069/104] fixed shared memory usage implementation for hipDynamicShared2.cpp test Change-Id: I34c72cb905f78de0f37e94174382e8be5c532028 [ROCm/hip commit: 28871ddd5b51b44981d166fe3caadd8b5a174663] --- projects/hip/tests/src/kernel/hipDynamicShared2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp index f4dcf0d1e8..0f6ebb4927 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -36,8 +36,8 @@ __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); + assert(B[i] > 1.0f && B[i] < 3.0f); } passed(); } From 60acbdb8345206e8ff9fe19f263c16bd13de8f17 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Fri, 10 Feb 2017 10:32:04 +0530 Subject: [PATCH 070/104] Build libhip_hcc.so as a fat binary Change-Id: Ie4f334d8f9576edf5df0f917f72083d7842eb193 [ROCm/hip commit: 75133e88b6887932cf3c1dfed93a95973751e12c] --- projects/hip/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9c469afbc1..a4dc040e40 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -186,6 +186,7 @@ if(HIP_PLATFORM STREQUAL "hcc") 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") + 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) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) From e09697c1cfbdfcaf7c5349002100bf98f0c1597d Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 10 Feb 2017 22:02:41 +0300 Subject: [PATCH 071/104] [HIPIFY] 'CHANGED LOC', 'TOTAL LOC' and 'CODE CHANGED (in lines)' are added to statistics. [ROCm/hip commit: 751db030c23d2af0069a8e3f6c4917c02459de7b] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 153 +++++++++++++++------ 1 file changed, 111 insertions(+), 42 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 543d527d58..468b42297c 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1698,11 +1698,20 @@ public: uint64_t countApiRepsUnsupported[API_LAST] = { 0 }; std::map cuda2hipConverted; std::map cuda2hipUnconverted; + std::set LOCs; protected: struct cuda2hipMap N; Replacements *Replace; + virtual void insertReplacement(const Replacement &rep, const FullSourceLoc &fullSL) { + Replace->insert(rep); + if (PrintStats) { + LOCs.insert(fullSL.getExpansionLineNumber()); + // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; + } + } + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; std::map *mapTotal = &cuda2hipConvertedTotal; @@ -1755,7 +1764,8 @@ 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"; @@ -1811,7 +1821,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"; @@ -1838,7 +1849,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"; @@ -1893,7 +1905,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"; @@ -1913,7 +1926,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"; @@ -1968,7 +1982,8 @@ 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) { @@ -2000,7 +2015,8 @@ 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()); @@ -2075,8 +2091,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; } @@ -2103,7 +2120,8 @@ private: 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"; @@ -2126,7 +2144,8 @@ private: 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"; @@ -2153,7 +2172,8 @@ private: 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"; @@ -2179,7 +2199,8 @@ private: 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"; @@ -2205,7 +2226,8 @@ private: 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 { @@ -2232,7 +2254,8 @@ private: 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].\n"; @@ -2256,7 +2279,8 @@ private: 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"; @@ -2282,7 +2306,8 @@ private: 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"; @@ -2324,8 +2349,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()); } } @@ -2351,7 +2377,8 @@ private: 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"; @@ -2379,7 +2406,8 @@ private: 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"; @@ -2440,8 +2468,10 @@ public: 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); + SourceLocation sl = SM->getLocForStartOfFile(SM->getMainFileID()); + Replacement Rep(*SM, sl, 0, repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; updateCounters(counter, repName); } @@ -2456,8 +2486,10 @@ 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); + SourceLocation sl = _sm->getLocForStartOfFile(_sm->getMainFileID()); + Replacement Rep(*_sm, sl, 0, repName); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; updateCounters(counter, repName); } @@ -2542,7 +2574,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; @@ -2575,10 +2607,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"; @@ -2657,7 +2704,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; @@ -2696,10 +2743,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"; @@ -2791,10 +2852,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) { @@ -2850,6 +2913,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()) { @@ -2857,10 +2922,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"); } @@ -2883,17 +2950,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; } From 37e317ddb41426aa9db5f39ad79a72bd40f58528 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 10 Feb 2017 13:32:13 -0600 Subject: [PATCH 072/104] v2: Fixed hipModule memory management 1. Changed test to assert for same hipFunction values 2. Added better memory management for hipModule Change-Id: I10d7aef13c215a2211e262f3c79017f26a17d9a7 [ROCm/hip commit: 378eb3fa5544e745cb06e62c100e2d2e12c2645d] --- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_module.cpp | 19 +++++++----- .../tests/src/runtimeApi/module/hipModule.cpp | 29 +++++++++---------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 28ae6a2e8e..5509e4aa10 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -343,7 +343,7 @@ public: std::string fileName; void *ptr; size_t size; - + std::list funcTrack; ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} }; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 63a6bffa94..1672dbf5d3 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -40,11 +40,9 @@ 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. + std::string _name; // TODO - review for performance cost. Name is just used for debug. }; -std::list hipFuncTracker; - template <> std::string ToString(hipFunction_t v) { @@ -236,6 +234,13 @@ 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); @@ -263,9 +268,9 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char &sym->_privateSegmentSize); CHECK_HSA(status, hipErrorNotFound); - strncpy(sym->_name, name, sizeof(sym->_name)); + sym->_name = name; *func = sym; - hipFuncTracker.push_back(*func); + hmod->funcTrack.push_back(*func); } return ihipLogStatus(ret); } @@ -321,7 +326,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, */ 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); + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name.c_str()); hsa_kernel_dispatch_packet_t aql; @@ -355,7 +360,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, 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); diff --git a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp index d7552ee1e6..1b7b62cff2 100644 --- a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp +++ b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp @@ -46,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(5); + memcpy(&argBuffer[3], &Ad, sizeof(void*)); + memcpy(&argBuffer[4], &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; } - - std::cout<<"Starting sleep"< Date: Fri, 10 Feb 2017 13:42:10 -0600 Subject: [PATCH 073/104] v3: added free for ihipModuleSymbol_t structures inside tracker Change-Id: Ib8041a05312c08cbdf2d4fee5e7cbae17df6efff [ROCm/hip commit: d03fe5a40dc70b0451ce6bbb8f394f95f0e85104] --- projects/hip/src/hip_module.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 1672dbf5d3..f21adf9691 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -218,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); } From 5df62556da3747fc976ca88abc1954d3a7150d51 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 19 Jan 2017 11:09:33 -0600 Subject: [PATCH 074/104] Set hip version correctly [ROCm/hip commit: bae7356b4299af25519184ea0126daea0de8eef8] --- projects/hip/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index a4dc040e40..9af405b836 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) From 9f5ab73c4efffba44fc76d911e725010ec6dc479 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 13 Feb 2017 16:01:50 +0530 Subject: [PATCH 075/104] Generate package config for cmake Change-Id: I73a0b21361bbe29e095dc515bdc70588ec722d57 [ROCm/hip commit: db36676f5de7ce9d84e022f86dc418e8bbc9c432] --- projects/hip/CMakeLists.txt | 33 +++++++++++++++++ projects/hip/hip-config.cmake.in | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 projects/hip/hip-config.cmake.in diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9af405b836..5bc31a2bd7 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -238,6 +238,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/hip-config.cmake.in b/projects/hip/hip-config.cmake.in new file mode 100644 index 0000000000..bcdaf0671d --- /dev/null +++ b/projects/hip/hip-config.cmake.in @@ -0,0 +1,62 @@ +@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() + +find_dependency(hcc) + +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@" ) + +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_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") +set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") From 31dfd8bb1fdfd66a56119feeb79ba75b077349ff Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 13 Feb 2017 18:13:49 +0300 Subject: [PATCH 076/104] [HIPIFY] Minor refactoring + insertHipHeaders function is added to Cuda2Hip class; + fix replacement ending for hip header. [ROCm/hip commit: c3ab4d5c5eb0ba90171154d4972b8be1737c6a27] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 34 +++++++++------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 468b42297c..cf9eae51b7 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1711,6 +1711,17 @@ protected: // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; } } + 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 updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; @@ -2464,17 +2475,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; - SourceLocation sl = SM->getLocForStartOfFile(SM->getMainFileID()); - Replacement Rep(*SM, sl, 0, repName); - FullSourceLoc fullSL(sl, *SM); - insertReplacement(Rep, fullSL); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(PP, *Result.SourceManager); } private: @@ -2483,16 +2484,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"; - SourceLocation sl = _sm->getLocForStartOfFile(_sm->getMainFileID()); - Replacement Rep(*_sm, sl, 0, repName); - FullSourceLoc fullSL(sl, *_sm); - insertReplacement(Rep, fullSL); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(Match, *_sm); } } // end anonymous namespace From af7455bd64a15fcdb3969766139af93d9a8a0077 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 16:28:05 +0300 Subject: [PATCH 077/104] [HIPIFY] Narrow cudaKernelCallExpr matcher. [Explanation] Narrow cudaKernelCallExpr matcher to isExpansionInMainFile() - to the file being actually converted (without system includes). But as for Thrust, there are *.inl files, which are nevertheless being expanded in main file. These files contain cuda kernel launches, which are not converted successfully by hipify, for instance: thrust/system/cuda/detail/detail/launch_closure.inl:98:23. [ToDo] File a bug on cudaKernelCallExpr matcher for conversion error (thrust\examples\cuda\). [ROCm/hip commit: d1cfcf55f19e919176b108b3c98d53bd29d7205f] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index cf9eae51b7..ec6a2dacff 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2494,7 +2494,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_"))))) From f6483f36a1d5f64c7a0ffdc0afb6e2401eb73f9e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 17:23:09 +0300 Subject: [PATCH 078/104] [HIPIFY] Fix warnings on unhandled refs. CUstream_st -> hipStream_t * CUevent_st -> hipEvent_t * (fixed, was -> hipEvent_t) Warning: [HIPIFY] warning: the following reference is not handled: 'CUstream_st' [struct var ptr]. (thrust/examples/cuda/async_reduce.cu) [ROCm/hip commit: a6db38c337f96f747547aae51ef7579cfa4ee83d] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index ec6a2dacff..e8caaf1af1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -450,6 +450,7 @@ struct cuda2hipMap { cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUstream_st"] = {"hipStream_t *", 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}; @@ -497,7 +498,7 @@ struct cuda2hipMap { // Events cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"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}; From ffedb9388ff77414633411ed1ec85623a7d56f82 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 17:34:10 +0300 Subject: [PATCH 079/104] [HIPIFY] Add more unhandled refs for opaque pointers. CUfunc_st -> hipFunction_t * CUctx_st -> hipCtx_t * CUmod_st -> hipModule_t * [ROCm/hip commit: b3941dd54645dbf5922c0ea82ed65425295caada] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index e8caaf1af1..46f8d48b0f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -429,6 +429,7 @@ struct cuda2hipMap { // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUfunc_st"] = {"hipFunction_t *", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; @@ -448,7 +449,9 @@ struct cuda2hipMap { cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUctx_st"] = {"hipCtx_t *", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUmod_st"] = {"hipModule_t *", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream_st"] = {"hipStream_t *", CONV_TYPE, API_DRIVER}; // Stream Flags From f8ad2028a4ed74d95a42a86677d5bc3414bf1fc0 Mon Sep 17 00:00:00 2001 From: scchan Date: Tue, 14 Feb 2017 11:52:09 -0500 Subject: [PATCH 080/104] calls isfinite,isinf,isnan from the std namespace on the host Change-Id: Ica2370075b89713eecfd96102e2f4e0ab9961ce4 [ROCm/hip commit: ad9d9b25c1b378a570d80fcfad6f680905b5466d] --- .../tests/src/deviceLib/hipDoublePrecisionMathHost.cpp | 8 ++++---- .../tests/src/deviceLib/hipSinglePrecisionMathHost.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 7f63d32e3d..33f4010a2b 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -73,9 +73,9 @@ __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); @@ -119,7 +119,7 @@ __host__ void double_precision_math_functions() //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); diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 83bc740e9e..cc554a5c36 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -76,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); @@ -121,7 +121,7 @@ __host__ void single_precision_math_functions() ///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); sinf(0.0f); From 8a8a7bc84343a10ff18d5700a0936b94b41d5ada Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 21:36:49 +0300 Subject: [PATCH 081/104] [HIPIFY] Add file:line:col info to [HIPIFY] warnings/errors. [ROCm/hip commit: e39ed24a5080741532a499e3c95bf9a9bc182c9e] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 127 +++++++++++++-------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 46f8d48b0f..1bcd03feca 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1695,7 +1695,8 @@ 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 }; @@ -1704,15 +1705,28 @@ public: 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()); - // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; } } void insertHipHeaders(Cuda2Hip *owner, const SourceManager &SM) { @@ -1727,6 +1741,11 @@ protected: } } + void printHipifyMessage(const SourceManager &SM, const SourceLocation &sl, const std::string &message, msgTypes msgType = HIPIFY_WARNING) { + FullSourceLoc fullSL(sl, SM); + llvm::errs() << "[HIPIFY] " << getMsgType(msgType) << ": " << mainFileName << ":" << fullSL.getExpansionLineNumber() << ":" << fullSL.getExpansionColumnNumber() << ": " << message << "\n"; + } + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; std::map *mapTotal = &cuda2hipConvertedTotal; @@ -1783,7 +1802,8 @@ protected: 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; @@ -1797,8 +1817,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(); @@ -2005,12 +2025,12 @@ private: 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)) { @@ -2037,7 +2057,8 @@ private: 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; } @@ -2121,6 +2142,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_"); @@ -2132,14 +2155,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); 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); } } } @@ -2151,19 +2173,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); 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; } @@ -2179,19 +2202,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); 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; } @@ -2206,19 +2230,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); 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; } @@ -2229,6 +2254,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(); @@ -2237,16 +2265,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); 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; @@ -2260,20 +2286,21 @@ private: ->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; - TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2284,21 +2311,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); 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; @@ -2309,6 +2337,9 @@ 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(); @@ -2317,15 +2348,13 @@ private: 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); 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; } @@ -2383,20 +2412,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); 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; } @@ -2407,6 +2437,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() @@ -2417,15 +2450,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); 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; @@ -2455,8 +2486,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); } @@ -2884,8 +2915,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); From 6f5ad4e7e66876271c4f80ace6af8e9495d365df Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 15 Feb 2017 19:48:31 +0300 Subject: [PATCH 082/104] [HIPIFY] [Fix] Crash on thrust example fallback_allocator.cu. https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/65 [Bug] Access violation in cudaStructVar matcher. StringRef name = structVar->getType() ->getAsStructureType() ->getDecl() // <--- Access Violation ->getNameAsString(); [Solution] Add isStructureType() check before getting type as Struct. [ToDo] Find case-studies for that StructVar matcher with types other than Struct. [ROCm/hip commit: 950434f4af34387993f5d92c0a39a4179de82932] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 1bcd03feca..3ed9af148c 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2282,25 +2282,27 @@ private: bool cudaStructVar(const MatchFinder::MatchResult &Result) { if (const VarDecl *structVar = Result.Nodes.getNodeAs("cudaStructVar")) { - StringRef name = structVar->getType() - ->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); + 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 { - std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; - printHipifyMessage(*SM, sl, msg); } return true; } From 3cd2b00059c3d8cb562f7ec14dc414e15a5f3eb1 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Mon, 13 Feb 2017 11:50:45 -0500 Subject: [PATCH 083/104] Squashed commit of the following: commit 931d3de6c1c903cfd47842bc5026a9294ac492b4 Author: Siu Chi Chan Date: Mon Feb 13 10:54:06 2017 -0500 only force to libstdc++ if the g++ is older than version 5 since hcc already defaults to libstdc++ with newer g++ commit 1ef8d71aa788de7b9eead4906fe56186f06d7d3f Author: scchan Date: Sun Feb 12 14:44:11 2017 -0500 remove hardcoded -lc++ in tests commit 5d99ef338eb3a66523cc9ddd139e86c6fd707b9c Author: scchan Date: Sun Feb 12 14:35:46 2017 -0500 force include libstdc++ headers and stdc++ only if g++ version < 5 since hcc uses libstdc++ by default if g++ > 5 is present commit a2bc21b24d100feefe91cd3cb2271238bda0738a Author: scchan Date: Fri Feb 10 04:36:27 2017 -0500 use hcc-config to generate compiler and linker flags Change-Id: I13a79629c0adfd75439a47d0488ff4fd619c55ba (cherry picked from commit 866e744e40cf1378af8a679b54959bf5226c340f) [ROCm/hip commit: 806deeb476e4cfce239552ac623ff6254f887a0a] --- projects/hip/CMakeLists.txt | 10 +++-- projects/hip/bin/hipcc | 37 ++++++------------- .../hip/tests/src/context/hipCtx_simple.cpp | 2 +- projects/hip/tests/src/hipHcc.cpp | 4 +- .../src/kernel/hipLanguageExtensions.cpp | 2 +- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 5bc31a2bd7..42926ad53d 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -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") @@ -185,12 +186,13 @@ if(HIP_PLATFORM STREQUAL "hcc") 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 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 hc_am) add_dependencies(hip_hcc_static hip_hcc) add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) add_dependencies(hip_device hip_hcc) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 2b84041e50..0dccb9bbc1 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -97,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) { @@ -104,34 +106,23 @@ 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"; # Add trace marker library: @@ -148,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) { @@ -271,7 +260,6 @@ foreach $arg (@ARGV) } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; $setStdLib = 1; } @@ -372,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; } 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/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/kernel/hipLanguageExtensions.cpp b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp index e519a1c2a8..ebb93a8e0d 100644 --- a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp +++ b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp @@ -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 */ From c98017e48380745d9905eab4f2286119975f4c63 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 19:38:35 +0300 Subject: [PATCH 084/104] [HIPIFY] Add safe type check for cudaChooseDevice matcher. [ROCm/hip commit: 93c1e31b36c4600054260a1d9d148996474704f2] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 3ed9af148c..b03731e56a 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2344,7 +2344,11 @@ private: 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()); From 2951f80caf71e98e8610293ae5e6d60ff06e4d53 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 20:00:36 +0300 Subject: [PATCH 085/104] [HIPIFY] Add CUDA Driver LAUNCH_PARAM defines. [ROCm/hip commit: bbbe5814c18ba27fa0ce32f30f2b7b642dbd4525] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index b03731e56a..dcc4b0f010 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -312,6 +312,11 @@ struct cuda2hipMap { 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}; From 07ffedbbf3e6e27d36982dda406627ccf18d8d6f Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 20:24:53 +0300 Subject: [PATCH 086/104] [HIPIFY] Add Inter-Process Communications (IPC) support. [ROCm/hip commit: ea95f3166a79ecd574e4994ddb3ac00d9af4ff23] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index dcc4b0f010..c9e6e9fc96 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -886,6 +886,7 @@ struct cuda2hipMap { 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}; @@ -928,6 +929,20 @@ struct cuda2hipMap { cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // 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}; + //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; From e97beff540020ff376d16fffb4dec862ea367e2b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 21:10:10 +0300 Subject: [PATCH 087/104] [HIPIFY] Add Channel (Textures) support. [ROCm/hip commit: b135b24200b7d05452d5ff82b7a0d37c38141cc5] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index c9e6e9fc96..7070eaca04 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -916,18 +916,25 @@ 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}; + + // Textures + cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // 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}; // Inter-Process Communications (IPC) // IPC types From 4883e82185a0a03375111b393d4928ba38099e4e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 21:26:44 +0300 Subject: [PATCH 088/104] [HIPIFY] Add more Memory Management functions [ROCm/hip commit: 7b44dbbe37586af4ac5b286f516f26f897985185] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 7070eaca04..cb71a24ef0 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -614,51 +614,55 @@ 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}; + 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}; + 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}; // 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["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocArray"] = {"hipMallocArray", CONV_MEM, API_RUNTIME}; + 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}; // 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}; From 451704189ec0079f15a713e6671808eba2f3db4b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 23:03:01 +0300 Subject: [PATCH 089/104] [HIPIFY] Add missing Memcpy functions. + cudaChooseDevice [ROCm/hip commit: 3b6990c8d6235195523048020ac9615e0f095ed6] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index cb71a24ef0..9818683010 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -621,11 +621,17 @@ struct cuda2hipMap { // 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["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}; + cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; + + // Memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; @@ -732,6 +738,7 @@ struct cuda2hipMap { 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}; From 3c7eb4ba4ed5db14adcb0511834e6fbbf673c5d4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 15:04:15 +0300 Subject: [PATCH 090/104] [HIPIFY] Add more Stream and Occupancy functions. [ROCm/hip commit: dc8e8caf4127491b0b49037fa0152b354bcab47e] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 9818683010..f26719cd48 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -724,6 +724,9 @@ struct cuda2hipMap { 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}; + // Stream Flags cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; @@ -846,6 +849,7 @@ struct cuda2hipMap { // Device cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_RUNTIME}; // Device Flags cuda2hipRename["cudaSetDeviceFlags"] = {"hipSetDeviceFlags", CONV_DEV, API_RUNTIME}; @@ -883,10 +887,11 @@ struct cuda2hipMap { cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Occupancy + cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER}; // 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["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}; From 6cd3764009827329b2df08e4c8e34a251468c812 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 17 Feb 2017 08:51:02 -0600 Subject: [PATCH 091/104] removed hipblas samples as it is not yet supported Change-Id: I354b710e652ce0d0413d670530ceb8b70f4993d5 [ROCm/hip commit: 39548fb02395ab84378950acfbb1043355699feb] --- .../samples/7_Advanced/hipblas_saxpy/Makefile | 34 ------- .../7_Advanced/hipblas_saxpy/saxpy.cublas.cpp | 94 ------------------- .../hipblas_saxpy/saxpy.hipblasref.cpp | 94 ------------------- 3 files changed, 222 deletions(-) delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp 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; -} From a1c15ab0fb90243baf28743a95bfb3f0517adb76 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 18:06:47 +0300 Subject: [PATCH 092/104] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP + 21 supported functions - 99 at least to support All the supported functions are also supported by hipify-clang (synced). [ROCm/hip commit: a35d4b75c5ccf1c7ab733a702b5643448d9cfad4] --- ..._Runtime_API_functions_supported_by_HIP.md | 96 ++++++++++--------- 1 file changed, 52 insertions(+), 44 deletions(-) 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..2df95177a0 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,32 +1,34 @@ +# 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. | +| `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | | `cudaDeviceGetPCIBusId` | | 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** @@ -41,8 +43,8 @@ | **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. | @@ -82,42 +84,50 @@ | **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,10 +141,10 @@ | `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. | @@ -145,13 +155,13 @@ | `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,11 +190,11 @@ | `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** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `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. | @@ -192,16 +202,16 @@ | `cudaGetChannelDesc` | | Get the channel descriptor of an array. | | `cudaGetTextureAlignmentOffset` | | Get the alignment offset of a texture. | | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | -| `cudaUnbindTexture` | | Unbinds a texture. | +| `cudaUnbindTexture` | `hipUnbindTexture` | 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,15 +229,14 @@ | `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** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -236,8 +245,7 @@ | `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,9 +259,9 @@ | `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. | @@ -261,7 +269,7 @@ | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | | `cudaUnbindTexture` | | Unbinds a texture. | -**18. Profiler Control** +**19. Profiler Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| From b01385b687c98073f105512873927526fd01a1c4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 18:09:08 +0300 Subject: [PATCH 093/104] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP Move hipBindTexture and hipUnbindTexture to "18. C++ API Routines" from "13. Texture Reference Management". They are C++, not C. [ROCm/hip commit: ee157678b97ad7d77759cb930b89359c79d67392] --- .../CUDA_Runtime_API_functions_supported_by_HIP.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 2df95177a0..2d77f4d82f 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 @@ -194,7 +194,7 @@ | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaBindTexture` | `hipBindTexture` | Binds a memory area to a texture. | +| `cudaBindTexture` | | 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. | @@ -202,7 +202,7 @@ | `cudaGetChannelDesc` | | Get the channel descriptor of an array. | | `cudaGetTextureAlignmentOffset` | | Get the alignment offset of a texture. | | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | -| `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | +| `cudaUnbindTexture` | | Unbinds a texture. | **14. Surface Reference Management** @@ -241,7 +241,7 @@ | **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. | @@ -267,7 +267,7 @@ | `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. | **19. Profiler Control** From 091d377ce5840d5a0ac31bd49f40f145f260fe20 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 18:28:59 +0300 Subject: [PATCH 094/104] [HIPIFY] Sync HIPIFY with HIP by data types. [ROCm/hip commit: 0cbe335c8fd9bac0f9f5704a5465939e14636f70] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 45 +++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index f26719cd48..218e9f47a1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -186,7 +186,7 @@ struct cuda2hipMap { // 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["cudaError"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; // CUDA Driver API error code only cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; @@ -433,8 +433,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}; - cuda2hipRename["CUfunc_st"] = {"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}; @@ -454,11 +457,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}; - cuda2hipRename["CUctx_st"] = {"hipCtx_t *", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUctx_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUmod_st"] = {"hipModule_t *", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUmod_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUstream_st"] = {"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}; @@ -505,8 +511,10 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; // Events + // pointer to CUevent_st cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"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}; @@ -619,6 +627,16 @@ struct cuda2hipMap { cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; + // Arrays + cuda2hipRename["cudaArray"] = {"hipArray", CONV_MEM, API_RUNTIME}; + // typedef struct cudaArray *cudaArray_t; + cuda2hipRename["cudaArray_t"] = {"hipArray *", CONV_MEM, API_RUNTIME}; + // typedef const struct cudaArray *cudaArray_const_t; + cuda2hipRename["cudaArray_const_t"] = {"const hipArray *", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + // Memcpy cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; @@ -631,7 +649,6 @@ struct cuda2hipMap { cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; - // Memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; @@ -857,9 +874,9 @@ struct cuda2hipMap { 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}; @@ -874,7 +891,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCache"] = {"hipFuncCache", CONV_CACHE, API_RUNTIME}; + 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}; @@ -941,6 +958,14 @@ struct cuda2hipMap { cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; // Textures + 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}; // Channel From 240b46d3b00d98db8b80fc6c6c88be0bd1f46f52 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 18:32:54 +0300 Subject: [PATCH 095/104] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP Section "20. Data types used by CUDA Runtime API and supported by HIP" is added. + 44 supported data types are added - 46 at least to support All the supported data types are also supported by hipify-clang (synced). [ROCm/hip commit: 5c11789358bbf7734b2b9f623b8c16c02207e7f2] --- ..._Runtime_API_functions_supported_by_HIP.md | 136 +++++++++++++++--- 1 file changed, 117 insertions(+), 19 deletions(-) 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 2d77f4d82f..a24490d458 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,6 +1,6 @@ # CUDA Runtime API functions supported by HIP -**1. Device Management** +## **1. Device Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -30,7 +30,7 @@ | `cudaSetDeviceFlags` | `hipSetDeviceFlags` | Sets flags to be used for device executions. | | `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. | -**2. Error Handling** +## **2. Error Handling** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -39,7 +39,7 @@ | `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** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -55,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** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -67,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** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -80,14 +80,14 @@ | `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` | `hipOccupancyMaxActiveBlocksPerMultiprocessor`| Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -**7. Execution Control [deprecated since 7.0]** +## **7. Execution Control [deprecated since 7.0]** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -95,7 +95,7 @@ | `cudaLaunch` | | Launches a device function. | | `cudaSetupArgument` | | Configure a device launch. | -**8. Memory Management** +## **8. Memory Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -155,13 +155,13 @@ | `make\_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | | `make\_cudaPos` | | Returns a cudaPos based on input parameters. | -**9. Unified Addressing** +## **9. Unified Addressing** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaPointerGetAttributes` | `hipPointerGetAttributes` | Returns attributes about a specified pointer. | -**10. Peer Device Memory Access** +## **10. Peer Device Memory Access** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -169,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. | -**11. OpenGL Interoperability** +## **11. OpenGL Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -178,7 +178,7 @@ | `cudaGraphicsGLRegisterImage` | | Register an OpenGL texture or renderbuffer object. | | `cudaWGLGetDevice` | | Gets the CUDA device associated with hGpu. | -**12. Graphics Interoperability** +## **12. Graphics Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -190,7 +190,7 @@ | `cudaGraphicsUnmapResources` | | Unmap graphics resources. | | `cudaGraphicsUnregisterResource` | | Unregisters a graphics resource for access by CUDA. | -**13. Texture Reference Management** +## **13. Texture Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -204,14 +204,14 @@ | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | | `cudaUnbindTexture` | | Unbinds a texture. | -**14. 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. | -**15. Texture Object Management** +## **15. Texture Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -221,7 +221,7 @@ | `cudaGetTextureObjectResourceViewDesc` | | Returns a texture object's resource view descriptor. | | `cudaGetTextureObjectTextureDesc` | | Returns a texture object's texture descriptor. | -**16. Surface Object Management** +## **16. Surface Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -229,14 +229,15 @@ | `cudaDestroySurfaceObject` | | Destroys a surface object. | | `cudaGetSurfaceObjectResourceDesc` | | Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject. | -**17. Version Management** +## **17. Version Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaDriverGetVersion` | `hipDriverGetVersion` | Returns the CUDA driver version. | | `cudaRuntimeGetVersion` | `hipRuntimeGetVersion` | Returns the CUDA Runtime version. | -**18. C++ API Routines (7.0 contains, 7.5 doesn’t)** +## **18. C++ API Routines** +*(7.0 contains, 7.5 doesn’t)* | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -269,10 +270,107 @@ | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | | `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | -**19. 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. | From d52c918b47ca645fa2b85eb0b5d1eacdb39f84a8 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:19:34 +0300 Subject: [PATCH 096/104] [HIPIFY] sync with HIP by HIP_UNSUPPORTED Runtime functions. [ROCm/hip commit: 6e611aa5744194cbe85f84e1d4e172ff004ddd4b] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 233 ++++++++++++++++----- 1 file changed, 175 insertions(+), 58 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 218e9f47a1..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, @@ -503,8 +507,7 @@ 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}; @@ -637,19 +640,29 @@ struct cuda2hipMap { cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; - // Memcpy + // 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["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}; 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 + // memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; @@ -657,10 +670,35 @@ struct cuda2hipMap { 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["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}; @@ -674,6 +712,12 @@ struct cuda2hipMap { 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}; @@ -719,50 +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["cudaStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamAddCallback"] = {"hipStreamAddCallback", 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["cudaChooseDevice"] = {"hipChooseDevice", 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}; @@ -864,11 +913,17 @@ 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["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", 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}; @@ -885,18 +940,35 @@ 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_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}; - 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}; @@ -957,7 +1029,7 @@ struct cuda2hipMap { cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; - // Textures + // Texture Reference Management cuda2hipRename["cudaTextureReadMode"] = {"hipTextureReadMode", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP @@ -968,6 +1040,13 @@ struct cuda2hipMap { 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}; @@ -976,6 +1055,27 @@ struct cuda2hipMap { 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 @@ -991,6 +1091,23 @@ struct cuda2hipMap { 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 cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; From cfb607a21dbd9f3a296e18777e16812c0b309837 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:21:47 +0300 Subject: [PATCH 097/104] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP cudaDeviceGetPCIBusId -> hipDeviceGetPCIBusId [ROCm/hip commit: bd9b674d3d55bbc23ebe7162a69342a08d701310] --- .../CUDA_Runtime_API_functions_supported_by_HIP.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 a24490d458..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 @@ -9,7 +9,7 @@ | `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. | +| `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. | @@ -151,9 +151,9 @@ | `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. | ## **9. Unified Addressing** From ed1915ad97ccbcbacc894db6e6975b368ee3172e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:26:40 +0300 Subject: [PATCH 098/104] [HIP] annotation update. cudaStreamAddCallback and cudaStreamWaitEvent were excluded from unsupported. [ROCm/hip commit: 2461ddd79d2513434593d6c550f4cc25cb38f8a3] --- projects/hip/include/hip/hcc_detail/hip_runtime_api.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 7abfffcc22..2cf14156a2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -511,12 +511,10 @@ const char *hipGetErrorString(hipError_t hipError); * @{ * * The following Stream APIs are not (yet) supported in HIP: - * - cudaStreamAddCallback * - cudaStreamAttachMemAsync * - cudaStreamCreateWithPriority * - cudaStreamGetPriority - * - cudaStreamWaitEvent - */ + */ /** From a89ef494545ae0c26abd534a0959212fa402f880 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 21 Feb 2017 14:44:37 -0600 Subject: [PATCH 099/104] added typedef for half and half2 Change-Id: Ic844fa31b64a0354484b418df71869c2807200cc [ROCm/hip commit: a1f39558603bee7a380c4c486fafdf18288fba28] --- projects/hip/include/hip/hcc_detail/hip_fp16.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 2c7c23440c..b28f92d451 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,6 +36,9 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; +typedef __half half; +typedef __half2 half2; + /* Half Arithmetic Functions */ From 7831962f6d93d94b890684e9284eae15f5f956c9 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 21 Feb 2017 22:03:13 -0600 Subject: [PATCH 100/104] Change order of find_dependency [ROCm/hip commit: 2e83e3a01d7118c286a55f106a0571a22b7f1d08] --- projects/hip/hip-config.cmake.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in index bcdaf0671d..2d607e605d 100644 --- a/projects/hip/hip-config.cmake.in +++ b/projects/hip/hip-config.cmake.in @@ -39,13 +39,16 @@ if (NOT _CMakeFindDependencyMacro_FOUND) endmacro() endif() -find_dependency(hcc) 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) @@ -58,5 +61,3 @@ set(HIP_BIN_INSTALL_DIR ${hip_BIN_INSTALL_DIR}) set(HIP_LIBRARIES ${hip_LIBRARIES}) set(HIP_LIBRARY ${hip_LIBRARY}) -set_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") -set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") From b98e396fc9a51a214621941f8a9993adf7950a86 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 21 Feb 2017 22:07:04 -0600 Subject: [PATCH 101/104] Update for lower case hip [ROCm/hip commit: 5dbf7e0618913463d4708085f4662d028cb46ef1] --- projects/hip/hip-config.cmake.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in index 2d607e605d..7e4468b94a 100644 --- a/projects/hip/hip-config.cmake.in +++ b/projects/hip/hip-config.cmake.in @@ -45,8 +45,8 @@ 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") +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" ) @@ -60,4 +60,6 @@ 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}) From 9e1a6a4013c69404b6198ab8a3220000469defd3 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 22 Feb 2017 13:42:03 -0600 Subject: [PATCH 102/104] Enable symbol tests Change-Id: I6bd036bf00c8051c8ff728ee60562c4ebd222160 [ROCm/hip commit: d52c5867f2d84394c7e110c1a98135e2b04a7b3b] --- projects/hip/src/device_util.h | 2 +- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/kernel/hipTestConstant.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/src/device_util.h b/projects/hip/src/device_util.h index e302b7db8a..ad8b2607dd 100644 --- a/projects/hip/src/device_util.h +++ b/projects/hip/src/device_util.h @@ -32,7 +32,7 @@ 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 diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index ed4d3902c5..49a719a8d4 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all + * BUILD: %t %s * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index 6d630f97ff..9aeaf59c00 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ From d24435ea9b19f7d1f965444da172b5869950d283 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 22 Feb 2017 19:16:35 -0600 Subject: [PATCH 103/104] added runtime api hipMemcpyFromSymbolAsync Change-Id: Ibaf925faf0ba464dd0ed6c5ea74c224c2ce38889 [ROCm/hip commit: 639fd4dd5e6f3c14d4ba00c3be266230055cc038] --- .../include/hip/hcc_detail/hip_runtime_api.h | 2 +- projects/hip/src/hip_hcc.cpp | 19 ++++++--- projects/hip/src/hip_hcc.h | 4 +- projects/hip/src/hip_memory.cpp | 42 +++++++++++++++++-- .../src/deviceLib/hipTestDeviceSymbol.cpp | 28 +++++++++---- 5 files changed, 74 insertions(+), 21 deletions(-) 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 2cf14156a2..2c75b584c4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1159,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. diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 68bf74cd21..a119ea1c54 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1780,7 +1780,7 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } -void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +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); @@ -1796,11 +1796,18 @@ void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const v } } -void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) { - 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 == 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) @@ -1903,7 +1910,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes 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 5509e4aa10..d7d92a221c 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -494,8 +494,8 @@ public: 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, const void* src, size_t sizeBytes, unsigned kind); - void lockedSymbolCopyAsync(hc::accelerator &acc, 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_memory.cpp b/projects/hip/src/hip_memory.cpp index df776aa707..cb265159ba 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -461,7 +461,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, src, count + offset, kind); + stream->lockedSymbolCopySync(acc, dst, (void*)src, count + offset, kind); // acc.memcpy_symbol(dst, (void*)src, count+offset); } else { return ihipLogStatus(hipErrorInvalidValue); @@ -493,6 +493,44 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ return ihipLogStatus(hipErrorInvalidSymbol); } + if (stream) { + try { + stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count + offset, kind); + } + catch (ihipException ex) { + e = ex._code; + } + } else { + e = hipErrorInvalidValue; + } + + 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); @@ -505,8 +543,6 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ } return ihipLogStatus(e); - - } //--- diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 49a719a8d4..476c5e0997 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s * RUN: %t * HIT_END */ @@ -32,44 +32,53 @@ THE SOFTWARE. #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, *Am, *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 Date: Thu, 23 Feb 2017 11:18:06 +0530 Subject: [PATCH 104/104] Fix export interfaces in hip-config.cmake Change-Id: Ifad4661ab17d7e6edb6ab300f1e92552ed917950 [ROCm/hip commit: 270054859affc8c17fc2d3643bdf92d05b32d53b] --- projects/hip/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 42926ad53d..9ebbd3325f 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -190,13 +190,19 @@ if(HIP_PLATFORM STREQUAL "hcc") 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 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 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)