diff --git a/.clang-tidy b/.clang-tidy index ce17f2942..c032bffd9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -194,6 +194,7 @@ Checks: "bugprone-*,\ -cert-err34-c,\ -cert-err58-cpp,\ -cert-flp30-c,\ + -cert-int09-c,\ -cert-msc30-c,\ -cert-msc32-c,\ -cert-msc50-cpp,\ @@ -207,6 +208,7 @@ Checks: "bugprone-*,\ clang-analyzer-*,\ -clang-analyzer-cplusplus.NewDelete,\ -clang-analyzer-cplusplus.NewDeleteLeaks,\ + -clang-analyzer-optin.core.EnumCastOutOfRange,\ -clang-analyzer-optin.performance.Padding,\ -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\ *googletest*,\ @@ -268,6 +270,7 @@ Checks: "bugprone-*,\ -modernize-pass-by-value,\ -modernize-redundant-void-arg,\ -modernize-return-braced-init-list,\ + -modernize-type-traits,\ -modernize-use-auto,\ -modernize-use-bool-literals,\ -modernize-use-default-member-init,\ @@ -280,6 +283,7 @@ Checks: "bugprone-*,\ -modernize-use-trailing-return-type,\ -modernize-use-using,\ performance-*,\ + -performance-enum-size,\ -performance-move-const-arg,\ -performance-move-constructor-init,\ -performance-noexcept-move-constructor,\ @@ -293,6 +297,7 @@ Checks: "bugprone-*,\ -readability-convert-member-functions-to-static, -readability-delete-null-pointer,\ -readability-else-after-return,\ + -readability-enum-initial-value,\ -readability-function-cognitive-complexity,\ -readability-function-size,\ -readability-implicit-bool-conversion,\ @@ -327,9 +332,10 @@ ExtraArgs: [ ] WarningsAsErrors: '*' HeaderFilterRegex: '.*' -AnalyzeTemporaryDtors: false FormatStyle: 'file' CheckOptions: + - key: bugprone-unused-return-value.AllowCastToVoid + value: true - key: readability-braces-around-statements.ShortStatementLines value: '1' - key: hicpp-braces-around-statements.ShortStatementLines diff --git a/.github/workflows/run_pr_tests.yml b/.github/workflows/run_pr_tests.yml index 08d62a5b4..5718dd372 100644 --- a/.github/workflows/run_pr_tests.yml +++ b/.github/workflows/run_pr_tests.yml @@ -104,7 +104,7 @@ jobs: - name: setup-ubuntu-clang-format run: - pip install clang-format==17.0.6 + pip install clang-format==19.1.0 - name: run clang-format run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d2d2c966..3947a0468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,7 @@ find_package(PythonInterp 3.6 REQUIRED) # which perform static analysis and style checking on source files. # When updating the version here, also update that used in the merge request # config -find_package(ClangTools 17 COMPONENTS clang-format clang-tidy) +find_package(ClangTools 19 COMPONENTS clang-format clang-tidy) if(TARGET ClangTools::clang-tidy) ca_option(CA_CLANG_TIDY_FLAGS STRING "Semi-color separated list of clang-tidy flags" "") diff --git a/README.md b/README.md index 7b60935c4..be752fbb3 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ To install the dependencies on Ubuntu, open the terminal and run: To install the recommended packages, run: ```sh $ sudo apt install -y ninja-build doxygen python3-pip - $ sudo pip3 install lit virtualenv cmakelint clang-format==17.0.6 + $ sudo pip3 install lit virtualenv cmakelint clang-format==19.1.0 ``` ### Compiling oneAPI Construction Kit diff --git a/clik/external/hal_cpu/source/hal_main.cpp b/clik/external/hal_cpu/source/hal_main.cpp index 79a01c9ec..9e51bbd07 100644 --- a/clik/external/hal_cpu/source/hal_main.cpp +++ b/clik/external/hal_cpu/source/hal_main.cpp @@ -58,7 +58,7 @@ class cpu_hal_platform : public hal::hal_t { cpu_hal_platform() { hal_device_info = &cpu_hal::setup_cpu_hal_device_info(); - constexpr static uint32_t implemented_api_version = 6; + static constexpr uint32_t implemented_api_version = 6; static_assert(implemented_api_version == hal_t::api_version, "Implemented API version for CPU HAL does not match hal.h"); hal_info.platform_name = hal_device_info->target_name; diff --git a/clik/include/clik_common.h b/clik/include/clik_common.h index 1501a8622..61d77237e 100644 --- a/clik/include/clik_common.h +++ b/clik/include/clik_common.h @@ -40,7 +40,7 @@ struct clik_buffer; struct CLIK_API clik_ndrange { - constexpr static uint32_t max_dimensions = 3; + static constexpr uint32_t max_dimensions = 3; // Origin of the work 'grid'. Used when the first item is not at (0, 0, 0). uint64_t offset[max_dimensions]; // Global size, i.e. total number of work-items in each dimension. diff --git a/clik/include/clik_hal_version.h b/clik/include/clik_hal_version.h index 837ff38db..484a2201d 100644 --- a/clik/include/clik_hal_version.h +++ b/clik/include/clik_hal_version.h @@ -19,6 +19,6 @@ #include -constexpr static uint32_t supported_hal_api_version = 6; +static constexpr uint32_t supported_hal_api_version = 6; #endif // _CLIK_CLIK_HAL_VERSION_H diff --git a/cmake/FindClangTools.cmake b/cmake/FindClangTools.cmake index b96d451ac..423fcd571 100644 --- a/cmake/FindClangTools.cmake +++ b/cmake/FindClangTools.cmake @@ -108,8 +108,8 @@ foreach(component ${ClangTools_FIND_COMPONENTS}) if(result EQUAL 0) # Strip all non-version text from the output, we only care about the - # . version components. - string(REGEX MATCH "[0-9]+\\.[0-9]+" version_string ${version_string}) + # version component. + string(REGEX MATCH "[0-9]+" version_string ${version_string}) if(version_string VERSION_EQUAL ClangTools_FIND_VERSION) # Success, found the correct version of the component. set(ClangTools_${component}_FOUND TRUE) diff --git a/doc/getting-started.rst b/doc/getting-started.rst index d0a6f9304..7367d9327 100644 --- a/doc/getting-started.rst +++ b/doc/getting-started.rst @@ -48,7 +48,7 @@ Recommended for Ubuntu 20.04 $ sudo apt update $ sudo apt install -y ninja-build doxygen python3-pip - $ sudo pip3 install lit virtualenv cmakelint clang-format==17.0.6 + $ sudo pip3 install lit virtualenv cmakelint clang-format==19.1.0 .. tip:: For ease of use ``python3`` and ``pip3`` can be symlinked to ``python`` and diff --git a/examples/hals/hal_cpu_client/source/hal_main.cpp b/examples/hals/hal_cpu_client/source/hal_main.cpp index d6a365626..093d724e8 100644 --- a/examples/hals/hal_cpu_client/source/hal_main.cpp +++ b/examples/hals/hal_cpu_client/source/hal_main.cpp @@ -21,7 +21,7 @@ namespace hal { class hal_cpu_socket_client : public hal::hal_socket_client { public: hal_cpu_socket_client() : hal_socket_client(0) { - constexpr static uint32_t implemented_api_version = 6; + static constexpr uint32_t implemented_api_version = 6; static_assert( implemented_api_version == hal_t::api_version, "Implemented API version for hal_socket_client does not match hal.h"); diff --git a/examples/hals/hal_refsi_tutorial/source/hal_main.cpp b/examples/hals/hal_refsi_tutorial/source/hal_main.cpp index 18d98d1b9..dc557834e 100644 --- a/examples/hals/hal_refsi_tutorial/source/hal_main.cpp +++ b/examples/hals/hal_refsi_tutorial/source/hal_main.cpp @@ -50,7 +50,7 @@ class refsi_tutorial_hal : public hal::hal_t { refsi_tutorial_hal() { const char *target_name = "RefSi M1 Tutorial"; - constexpr static uint32_t implemented_api_version = 6; + static constexpr uint32_t implemented_api_version = 6; static_assert(implemented_api_version == hal_t::api_version, "Implemented API version for RefSi HAL does not match hal.h"); hal_info.platform_name = target_name; diff --git a/examples/refsi/hal_refsi/external/refsidrv/include/common/elf_loader.h b/examples/refsi/hal_refsi/external/refsidrv/include/common/elf_loader.h index 705a4a53a..75b8031fa 100644 --- a/examples/refsi/hal_refsi/external/refsidrv/include/common/elf_loader.h +++ b/examples/refsi/hal_refsi/external/refsidrv/include/common/elf_loader.h @@ -58,7 +58,7 @@ class ELFProgram { reg_t find_symbol(const char *name) const; - constexpr static uint64_t invalid_address = ~0ull; + static constexpr uint64_t invalid_address = ~0ull; private: bool read_header(MemoryDevice &src, unit_id_t unit); diff --git a/examples/refsi/hal_refsi/external/refsidrv/include/refsidrv/refsi_device_g.h b/examples/refsi/hal_refsi/external/refsidrv/include/refsidrv/refsi_device_g.h index 246a36f59..542e455a4 100644 --- a/examples/refsi/hal_refsi/external/refsidrv/include/refsidrv/refsi_device_g.h +++ b/examples/refsi/hal_refsi/external/refsidrv/include/refsidrv/refsi_device_g.h @@ -45,8 +45,8 @@ struct RefSiGDevice : public RefSiDevice { refsi_result setupHartLocalWindow(unsigned index); void pre_run_kernel(slim_sim_t &sim, reg_t entry_point_addr); - constexpr const static unsigned window_index_elf = 0; - constexpr const static unsigned window_index_harts = 1; + static constexpr const unsigned window_index_elf = 0; + static constexpr const unsigned window_index_harts = 1; unsigned max_harts = REFSI_SIM_MAX_HARTS; refsi_addr_t elf_mem_mapped_addr = 0; refsi_addr_t harts_mem_mapped_addr = 0; diff --git a/examples/refsi/hal_refsi/source/hal_main.cpp b/examples/refsi/hal_refsi/source/hal_main.cpp index b8f6730b5..14f33e9f7 100644 --- a/examples/refsi/hal_refsi/source/hal_main.cpp +++ b/examples/refsi/hal_refsi/source/hal_main.cpp @@ -121,7 +121,7 @@ class refsi_hal : public hal::hal_t { } refsi_hal() { - constexpr static uint32_t implemented_api_version = 6; + static constexpr uint32_t implemented_api_version = 6; static_assert(implemented_api_version == hal_t::api_version, "Implemented API version for RefSi HAL does not match hal.h"); hal_info.num_devices = 1; diff --git a/hal/hal_remote/include/hal_remote/hal_transmitter.h b/hal/hal_remote/include/hal_remote/hal_transmitter.h index 73527690c..fa0dee593 100644 --- a/hal/hal_remote/include/hal_remote/hal_transmitter.h +++ b/hal/hal_remote/include/hal_remote/hal_transmitter.h @@ -32,7 +32,7 @@ class hal_transmitter { /// Receive `size` bytes of data into `data` /// @return true if the receive succeeds virtual bool receive(void *data, uint32_t size) = 0; - virtual ~hal_transmitter(){}; + virtual ~hal_transmitter() {}; void enable_debug(bool debug_enabled) { debug = debug_enabled; } bool debug_enabled() { return debug; } diff --git a/hal/include/hal.h b/hal/include/hal.h index 58190996f..04c717495 100644 --- a/hal/include/hal.h +++ b/hal/include/hal.h @@ -35,8 +35,8 @@ namespace hal { /// a hal. it provides access to device memory, program loading, execution /// and information queries. struct hal_device_t { - hal_device_t(hal_device_info_t *device_info) : device_info(device_info){}; - virtual ~hal_device_t(){}; + hal_device_t(hal_device_info_t *device_info) : device_info(device_info) {}; + virtual ~hal_device_t() {}; /// @brief Find a specific kernel function in a compiled program. /// diff --git a/modules/cargo/include/cargo/allocator.h b/modules/cargo/include/cargo/allocator.h index 12c1b8231..d69778003 100644 --- a/modules/cargo/include/cargo/allocator.h +++ b/modules/cargo/include/cargo/allocator.h @@ -78,7 +78,7 @@ class mallocator { /// @brief Free allocated memory. /// /// @param pointer Pointer to allocated memory. - void free(value_type *pointer) { cargo::free(pointer); } + void free(value_type *pointer) { cargo::free(static_cast(pointer)); } /// @brief Allocate and construct an object. /// diff --git a/modules/cargo/include/cargo/detail/expected.h b/modules/cargo/include/cargo/detail/expected.h index e48352606..fff043699 100644 --- a/modules/cargo/include/cargo/detail/expected.h +++ b/modules/cargo/include/cargo/detail/expected.h @@ -43,11 +43,9 @@ namespace detail { // Trait for checking if a type is a cargo::expected template -struct is_expected_impl : std::false_type {}; +static constexpr bool is_expected_v = false; template -struct is_expected_impl> : std::true_type {}; -template -using is_expected = is_expected_impl>; +static constexpr bool is_expected_v> = true; template using expected_enable_forward_value = @@ -69,16 +67,13 @@ using expected_enable_from_other = !std::is_convertible_v &, T> && !std::is_convertible_v &&, T>>; -template -using is_void_or = std::conditional_t, std::true_type, U>; - template -using is_copy_constructible_or_void = - is_void_or>; +static constexpr bool is_copy_constructible_or_void_v = + std::is_void_v || std::is_copy_constructible_v; template -using is_move_constructible_or_void = - is_void_or>; +static constexpr bool is_move_constructible_or_void_v = + std::is_void_v || std::is_move_constructible_v; struct no_init_t {}; static constexpr no_init_t no_init{}; @@ -342,19 +337,21 @@ struct expected_operations_base : expected_storage_base { template void construct(Args &&...args) noexcept { - new (std::addressof(this->m_val)) T(std::forward(args)...); + new (static_cast(std::addressof(this->m_val))) + T(std::forward(args)...); this->m_has_val = true; } template void construct_with(Rhs &&rhs) noexcept { - new (std::addressof(this->m_val)) T(std::forward(rhs).get()); + new (static_cast(std::addressof(this->m_val))) + T(std::forward(rhs).get()); this->m_has_val = true; } template void construct_error(Args &&...args) noexcept { - new (std::addressof(this->m_unexpect)) + new (static_cast(std::addressof(this->m_unexpect))) unexpected(std::forward(args)...); this->m_has_val = false; } @@ -429,7 +426,7 @@ struct expected_operations_base : expected_storage_base { template void construct_error(Args &&...args) noexcept { - new (std::addressof(this->m_unexpect)) + new (static_cast(std::addressof(this->m_unexpect))) unexpected(std::forward(args)...); this->m_has_val = false; } @@ -463,9 +460,9 @@ struct expected_operations_base : expected_storage_base { // This class manages conditionally having a trivial copy constructor // This specialization is for when T and E are trivially copy constructible template >::value && - std::is_trivially_copy_constructible_v> + bool = (std::is_void_v || + std::is_trivially_copy_constructible_v) && + std::is_trivially_copy_constructible_v> struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; }; @@ -492,9 +489,9 @@ struct expected_copy_base : expected_operations_base { // This class manages conditionally having a trivial move constructor template >::value && - std::is_trivially_move_constructible_v> + bool = (std::is_void_v || + std::is_trivially_move_constructible_v) && + std::is_trivially_move_constructible_v> struct expected_move_base : expected_copy_base { using expected_copy_base::expected_copy_base; }; @@ -519,15 +516,14 @@ struct expected_move_base : expected_copy_base { }; // This class manages conditionally having a trivial copy assignment operator -template < - class T, class E, - bool = - is_void_or, - std::is_trivially_copy_constructible, - std::is_trivially_destructible>>::value && - std::is_trivially_copy_assignable_v && - std::is_trivially_copy_constructible_v && - std::is_trivially_destructible_v> +template || + (std::is_trivially_copy_assignable_v && + std::is_trivially_copy_constructible_v && + std::is_trivially_destructible_v)) && + std::is_trivially_copy_assignable_v && + std::is_trivially_copy_constructible_v && + std::is_trivially_destructible_v> struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; }; @@ -549,15 +545,14 @@ struct expected_copy_assign_base : expected_move_base { }; // This class manages conditionally having a trivial move assignment operator -template < - class T, class E, - bool = is_void_or< - T, conjunction, - std::is_trivially_move_constructible, - std::is_trivially_move_assignable>>::value && - std::is_trivially_destructible_v && - std::is_trivially_move_constructible_v && - std::is_trivially_move_assignable_v> +template || + (std::is_trivially_destructible_v && + std::is_trivially_move_constructible_v && + std::is_trivially_move_assignable_v)) && + std::is_trivially_destructible_v && + std::is_trivially_move_constructible_v && + std::is_trivially_move_assignable_v> struct expected_move_assign_base : expected_copy_assign_base { using expected_copy_assign_base::expected_copy_assign_base; }; diff --git a/modules/cargo/include/cargo/detail/optional.h b/modules/cargo/include/cargo/detail/optional.h index 7dd496984..1efa9f0b0 100644 --- a/modules/cargo/include/cargo/detail/optional.h +++ b/modules/cargo/include/cargo/detail/optional.h @@ -84,7 +84,7 @@ using enable_from_other = template using enable_assign_forward = std::enable_if_t< !std::is_same_v, std::decay_t> && - !conjunction, std::is_same>>::value && + !(std::is_scalar_v && std::is_same_v>) && std::is_constructible_v && std::is_assignable_v>; template @@ -162,7 +162,8 @@ struct optional_operations_base : optional_storage_base { template void construct(Args &&...args) { - new (std::addressof(this->m_value)) T(std::forward(args)...); + new (static_cast(std::addressof(this->m_value))) + T(std::forward(args)...); this->m_has_value = true; } diff --git a/modules/cargo/include/cargo/dynamic_array.h b/modules/cargo/include/cargo/dynamic_array.h index 524a80b11..df8b8fdf0 100644 --- a/modules/cargo/include/cargo/dynamic_array.h +++ b/modules/cargo/include/cargo/dynamic_array.h @@ -93,8 +93,9 @@ class dynamic_array final { if (nullptr == Begin) { return cargo::bad_alloc; } - std::for_each(Begin, End, - [&](reference item) { new (&item) value_type(); }); + std::for_each(Begin, End, [&](reference item) { + new (static_cast(std::addressof(item))) value_type(); + }); return cargo::success; } diff --git a/modules/cargo/include/cargo/error.h b/modules/cargo/include/cargo/error.h index b4ac11558..5b6a6f42b 100644 --- a/modules/cargo/include/cargo/error.h +++ b/modules/cargo/include/cargo/error.h @@ -133,8 +133,8 @@ class error_or { !(sizeof...(Args) == 0 && std::is_same_v>)>> error_or(First &&first, Args &&...args) : HasError(false) { - new (&ValueStorage) value_storage_type(std::forward(first), - std::forward(args)...); + new (static_cast(&ValueStorage)) value_storage_type( + std::forward(first), std::forward(args)...); } /// @brief Copy constructor. diff --git a/modules/cargo/include/cargo/expected.h b/modules/cargo/include/cargo/expected.h index eb4fd6cfb..8ccbe3bdb 100644 --- a/modules/cargo/include/cargo/expected.h +++ b/modules/cargo/include/cargo/expected.h @@ -246,8 +246,8 @@ template class expected : private detail::expected_move_assign_base, E>, private detail::delete_ctor_base< - detail::is_copy_constructible_or_void>::value && - detail::is_copy_constructible_or_void::value, + detail::is_copy_constructible_or_void_v> && + detail::is_copy_constructible_or_void_v, std::is_move_constructible_v> && std::is_move_constructible_v>, private detail::delete_assign_base< @@ -496,12 +496,11 @@ class expected class U = T, class G = T, std::enable_if_t> * = nullptr, std::enable_if_t> * = nullptr, - std::enable_if_t<(!std::is_same_v, std::decay_t> && - !conjunction, - std::is_same>>::value && - std::is_constructible_v && - std::is_assignable_v && - std::is_nothrow_move_constructible_v)> * = nullptr> + std::enable_if_t< + (!std::is_same_v, std::decay_t> && + !(std::is_scalar_v && std::is_same_v>) && + std::is_constructible_v && std::is_assignable_v && + std::is_nothrow_move_constructible_v)> * = nullptr> expected &operator=(U &&v) { if (has_value()) { val() = std::forward(v); @@ -521,12 +520,11 @@ class expected class U = T, class G = T, std::enable_if_t> * = nullptr, std::enable_if_t> * = nullptr, - std::enable_if_t<(!std::is_same_v, std::decay_t> && - !conjunction, - std::is_same>>::value && - std::is_constructible_v && - std::is_assignable_v && - std::is_nothrow_move_constructible_v)> * = nullptr> + std::enable_if_t< + (!std::is_same_v, std::decay_t> && + !(std::is_scalar_v && std::is_same_v>) && + std::is_constructible_v && std::is_assignable_v && + std::is_nothrow_move_constructible_v)> * = nullptr> expected &operator=(U &&v) { if (has_value()) { val() = std::forward(v); @@ -948,10 +946,10 @@ class expected /// /// @param rhs The expected to swap with this. void swap(expected &rhs) noexcept( - std::is_nothrow_move_constructible_v && noexcept( - swap(std::declval(), std::declval())) && - std::is_nothrow_move_constructible_v && noexcept( - swap(std::declval(), std::declval()))) { + std::is_nothrow_move_constructible_v && + noexcept(swap(std::declval(), std::declval())) && + std::is_nothrow_move_constructible_v && + noexcept(swap(std::declval(), std::declval()))) { if (has_value() && rhs.has_value()) { using std::swap; swap(val(), rhs.val()); @@ -1103,9 +1101,9 @@ class expected /// otherwise returns the default value. template constexpr T value_or(U &&v) const & { - static_assert(std::is_copy_constructible::value && - std::is_convertible::value, - "T must be copy-constructible and convertible to from U&&"); + static_assert( + std::is_copy_constructible_v && std::is_convertible_v, + "T must be copy-constructible and convertible to from U&&"); return bool(*this) ? **this : static_cast(std::forward(v)); } @@ -1117,9 +1115,9 @@ class expected /// one, otherwise returns the default value. template constexpr T value_or(U &&v) && { - static_assert(std::is_move_constructible::value && - std::is_convertible::value, - "T must be move-constructible and convertible to from U&&"); + static_assert( + std::is_move_constructible_v && std::is_convertible_v, + "T must be move-constructible and convertible to from U&&"); return bool(*this) ? std::move(**this) : static_cast(std::forward(v)); } @@ -1187,7 +1185,7 @@ template ())), std::enable_if_t>> * = nullptr> constexpr auto and_then_impl(Exp &&exp, F &&f) { - static_assert(detail::is_expected::value, "F must return an expected"); + static_assert(detail::is_expected_v, "F must return an expected"); return exp.has_value() ? cargo::invoke(std::forward(f), *std::forward(exp)) : Ret(unexpect, exp.error()); @@ -1198,7 +1196,7 @@ template ())), std::enable_if_t>> * = nullptr> constexpr auto and_then_impl(Exp &&exp, F &&f) { - static_assert(detail::is_expected::value, "F must return an expected"); + static_assert(detail::is_expected_v, "F must return an expected"); return exp.has_value() ? cargo::invoke(std::forward(f)) : Ret(unexpect, exp.error()); } @@ -1257,7 +1255,7 @@ template ().error())), std::enable_if_t> * = nullptr> constexpr auto or_else_impl(Exp &&exp, F &&f) { - static_assert(detail::is_expected::value, "F must return an expected"); + static_assert(detail::is_expected_v, "F must return an expected"); return exp.has_value() ? std::forward(exp) : cargo::invoke(std::forward(f), std::forward(exp).error()); @@ -1292,9 +1290,11 @@ std::decay_t or_else_impl(Exp &&exp, F &&f) { template constexpr bool operator==(const expected &lhs, const expected &rhs) { - return (lhs.has_value() != rhs.has_value()) - ? false - : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs); + if (lhs.has_value()) { + return rhs.has_value() && *lhs == *rhs; + } else { + return !rhs.has_value() && lhs.error() == rhs.error(); + } } /// @brief Determine if an expected is not equal to another. @@ -1310,9 +1310,11 @@ constexpr bool operator==(const expected &lhs, template constexpr bool operator!=(const expected &lhs, const expected &rhs) { - return (lhs.has_value() != rhs.has_value()) - ? true - : (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs); + if (lhs.has_value()) { + return !rhs.has_value() || *lhs != *rhs; + } else { + return rhs.has_value() || lhs.error() != rhs.error(); + } } /// @brief Determine if an expected is equal to a value. diff --git a/modules/cargo/include/cargo/optional.h b/modules/cargo/include/cargo/optional.h index 8d0b27cae..b0ab4b5de 100644 --- a/modules/cargo/include/cargo/optional.h +++ b/modules/cargo/include/cargo/optional.h @@ -758,7 +758,7 @@ class optional : private detail::optional_move_assign_base>, /// @return The constructed value. template T &emplace(Args &&...args) { - static_assert(std::is_constructible::value, + static_assert(std::is_constructible_v, "T must be constructible with Args"); *this = nullopt; this->construct(std::forward(args)...); @@ -901,18 +901,18 @@ class optional : private detail::optional_move_assign_base>, /// @return The stored value if there is one, otherwise `u`. template constexpr T value_or(U &&u) const & { - static_assert(std::is_copy_constructible::value && - std::is_convertible::value, - "T must be copy constructible and convertible from U"); + static_assert( + std::is_copy_constructible_v && std::is_convertible_v, + "T must be copy constructible and convertible from U"); return has_value() ? **this : static_cast(std::forward(u)); } /// @return The stored value if there is one, otherwise `u`. template constexpr T value_or(U &&u) && { - static_assert(std::is_move_constructible::value && - std::is_convertible::value, - "T must be move constructible and convertible from U"); + static_assert( + std::is_move_constructible_v && std::is_convertible_v, + "T must be move constructible and convertible from U"); return has_value() ? **this : static_cast(std::forward(u)); } @@ -931,8 +931,7 @@ class optional : private detail::optional_move_assign_base>, /// relational operators. Otherwise `lhs` and `rhs` are equal only if they are /// both empty. template -inline constexpr bool operator==(const optional &lhs, - const optional &rhs) { +constexpr bool operator==(const optional &lhs, const optional &rhs) { return lhs.has_value() == rhs.has_value() && (!lhs.has_value() || *lhs == *rhs); } @@ -943,8 +942,7 @@ inline constexpr bool operator==(const optional &lhs, /// relational operators. Otherwise `lhs` and `rhs` are equal only if they are /// both empty. template -inline constexpr bool operator!=(const optional &lhs, - const optional &rhs) { +constexpr bool operator!=(const optional &lhs, const optional &rhs) { return lhs.has_value() != rhs.has_value() || (lhs.has_value() && *lhs != *rhs); } @@ -955,8 +953,7 @@ inline constexpr bool operator!=(const optional &lhs, /// relational operators. Otherwise `lhs` is less than `rhs` only if `rhs` is /// empty and `lhs` is not. template -inline constexpr bool operator<(const optional &lhs, - const optional &rhs) { +constexpr bool operator<(const optional &lhs, const optional &rhs) { return rhs.has_value() && (!lhs.has_value() || *lhs < *rhs); } @@ -966,8 +963,7 @@ inline constexpr bool operator<(const optional &lhs, /// relational operators. Otherwise `lhs` is less than `rhs` only if `rhs` is /// empty and `lhs` is not. template -inline constexpr bool operator>(const optional &lhs, - const optional &rhs) { +constexpr bool operator>(const optional &lhs, const optional &rhs) { return lhs.has_value() && (!rhs.has_value() || *lhs > *rhs); } @@ -977,8 +973,7 @@ inline constexpr bool operator>(const optional &lhs, /// relational operators. Otherwise `lhs` is less than `rhs` only if `rhs` is /// empty and `lhs` is not. template -inline constexpr bool operator<=(const optional &lhs, - const optional &rhs) { +constexpr bool operator<=(const optional &lhs, const optional &rhs) { return !lhs.has_value() || (rhs.has_value() && *lhs <= *rhs); } @@ -988,8 +983,7 @@ inline constexpr bool operator<=(const optional &lhs, /// relational operators. Otherwise `lhs` is less than `rhs` only if `rhs` is /// empty and `lhs` is not. template -inline constexpr bool operator>=(const optional &lhs, - const optional &rhs) { +constexpr bool operator>=(const optional &lhs, const optional &rhs) { return !rhs.has_value() || (lhs.has_value() && *lhs >= *rhs); } @@ -997,7 +991,7 @@ inline constexpr bool operator>=(const optional &lhs, /// /// @return The optional is equal to `nullopt` only if it has no value. template -inline constexpr bool operator==(const optional &lhs, nullopt_t) { +constexpr bool operator==(const optional &lhs, nullopt_t) { return !lhs.has_value(); } @@ -1005,7 +999,7 @@ inline constexpr bool operator==(const optional &lhs, nullopt_t) { /// /// @return The optional is equal to `nullopt` only if it has no value. template -inline constexpr bool operator==(nullopt_t, const optional &rhs) { +constexpr bool operator==(nullopt_t, const optional &rhs) { return !rhs.has_value(); } @@ -1013,7 +1007,7 @@ inline constexpr bool operator==(nullopt_t, const optional &rhs) { /// /// @return The optional is equal to `nullopt` only if it has no value. template -inline constexpr bool operator!=(const optional &lhs, nullopt_t) { +constexpr bool operator!=(const optional &lhs, nullopt_t) { return lhs.has_value(); } @@ -1021,7 +1015,7 @@ inline constexpr bool operator!=(const optional &lhs, nullopt_t) { /// /// @return The optional is equal to `nullopt` only if it has no value. template -inline constexpr bool operator!=(nullopt_t, const optional &rhs) { +constexpr bool operator!=(nullopt_t, const optional &rhs) { return rhs.has_value(); } @@ -1029,7 +1023,7 @@ inline constexpr bool operator!=(nullopt_t, const optional &rhs) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator<(const optional &, nullopt_t) { +constexpr bool operator<(const optional &, nullopt_t) { return false; } @@ -1037,7 +1031,7 @@ inline constexpr bool operator<(const optional &, nullopt_t) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator<(nullopt_t, const optional &rhs) { +constexpr bool operator<(nullopt_t, const optional &rhs) { return rhs.has_value(); } @@ -1045,7 +1039,7 @@ inline constexpr bool operator<(nullopt_t, const optional &rhs) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator<=(const optional &lhs, nullopt_t) { +constexpr bool operator<=(const optional &lhs, nullopt_t) { return !lhs.has_value(); } @@ -1053,7 +1047,7 @@ inline constexpr bool operator<=(const optional &lhs, nullopt_t) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator<=(nullopt_t, const optional &) { +constexpr bool operator<=(nullopt_t, const optional &) { return true; } @@ -1061,7 +1055,7 @@ inline constexpr bool operator<=(nullopt_t, const optional &) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator>(const optional &lhs, nullopt_t) { +constexpr bool operator>(const optional &lhs, nullopt_t) { return lhs.has_value(); } @@ -1069,7 +1063,7 @@ inline constexpr bool operator>(const optional &lhs, nullopt_t) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator>(nullopt_t, const optional &) { +constexpr bool operator>(nullopt_t, const optional &) { return false; } @@ -1077,7 +1071,7 @@ inline constexpr bool operator>(nullopt_t, const optional &) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator>=(const optional &, nullopt_t) { +constexpr bool operator>=(const optional &, nullopt_t) { return true; } @@ -1085,7 +1079,7 @@ inline constexpr bool operator>=(const optional &, nullopt_t) { /// /// @return The optional is less than `nullopt` only if it has no value. template -inline constexpr bool operator>=(nullopt_t, const optional &rhs) { +constexpr bool operator>=(nullopt_t, const optional &rhs) { return !rhs.has_value(); } @@ -1095,7 +1089,7 @@ inline constexpr bool operator>=(nullopt_t, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// not equal to the value. template -inline constexpr bool operator==(const optional &lhs, const U &rhs) { +constexpr bool operator==(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs == rhs : false; } @@ -1105,7 +1099,7 @@ inline constexpr bool operator==(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// not equal to the value. template -inline constexpr bool operator==(const U &lhs, const optional &rhs) { +constexpr bool operator==(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs == *rhs : false; } @@ -1115,7 +1109,7 @@ inline constexpr bool operator==(const U &lhs, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// not equal to the value. template -inline constexpr bool operator!=(const optional &lhs, const U &rhs) { +constexpr bool operator!=(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs != rhs : true; } @@ -1125,7 +1119,7 @@ inline constexpr bool operator!=(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// not equal to the value. template -inline constexpr bool operator!=(const U &lhs, const optional &rhs) { +constexpr bool operator!=(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs != *rhs : true; } @@ -1135,7 +1129,7 @@ inline constexpr bool operator!=(const U &lhs, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator<(const optional &lhs, const U &rhs) { +constexpr bool operator<(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs < rhs : true; } @@ -1145,7 +1139,7 @@ inline constexpr bool operator<(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator<(const U &lhs, const optional &rhs) { +constexpr bool operator<(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs < *rhs : false; } @@ -1155,7 +1149,7 @@ inline constexpr bool operator<(const U &lhs, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator<=(const optional &lhs, const U &rhs) { +constexpr bool operator<=(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs <= rhs : true; } @@ -1165,7 +1159,7 @@ inline constexpr bool operator<=(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator<=(const U &lhs, const optional &rhs) { +constexpr bool operator<=(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs <= *rhs : false; } @@ -1175,7 +1169,7 @@ inline constexpr bool operator<=(const U &lhs, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator>(const optional &lhs, const U &rhs) { +constexpr bool operator>(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs > rhs : false; } @@ -1185,7 +1179,7 @@ inline constexpr bool operator>(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator>(const U &lhs, const optional &rhs) { +constexpr bool operator>(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs > *rhs : true; } @@ -1195,7 +1189,7 @@ inline constexpr bool operator>(const U &lhs, const optional &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator>=(const optional &lhs, const U &rhs) { +constexpr bool operator>=(const optional &lhs, const U &rhs) { return lhs.has_value() ? *lhs >= rhs : false; } @@ -1205,7 +1199,7 @@ inline constexpr bool operator>=(const optional &lhs, const U &rhs) { /// using `T`s relational operators. Otherwise, the optional is considered /// less than the value. template -inline constexpr bool operator>=(const U &lhs, const optional &rhs) { +constexpr bool operator>=(const U &lhs, const optional &rhs) { return rhs.has_value() ? lhs >= *rhs : true; } @@ -1220,20 +1214,20 @@ void swap(optional &lhs, optional &rhs) { /// @brief Creates an optional from `v`. template -inline constexpr optional> make_optional(T &&v) { +constexpr optional> make_optional(T &&v) { return optional>(std::forward(v)); } /// @brief Creates an optional from `args`. template -inline constexpr optional make_optional(Args &&...args) { +constexpr optional make_optional(Args &&...args) { return optional(in_place, std::forward(args)...); } /// @brief Creates an optional from `il` and `args`. template -inline constexpr optional make_optional(std::initializer_list il, - Args &&...args) { +constexpr optional make_optional(std::initializer_list il, + Args &&...args) { return optional(in_place, il, std::forward(args)...); } diff --git a/modules/cargo/include/cargo/small_vector.h b/modules/cargo/include/cargo/small_vector.h index 07212220e..e30cfd508 100644 --- a/modules/cargo/include/cargo/small_vector.h +++ b/modules/cargo/include/cargo/small_vector.h @@ -631,7 +631,7 @@ class small_vector { } iterator position = Begin + index; std::move_backward(position, End, End + 1); - new (position) value_type(std::forward(args)...); + new (static_cast(position)) value_type(std::forward(args)...); setEnd(End + 1); return position; } @@ -689,7 +689,7 @@ class small_vector { if (auto error = extend(1)) { return error; } - new (End) value_type(value); + new (static_cast(End)) value_type(value); setEnd(End + 1); return cargo::success; } @@ -709,7 +709,7 @@ class small_vector { if (auto error = extend(1)) { return error; } - new (End) value_type(std::move(value)); + new (static_cast(End)) value_type(std::move(value)); setEnd(End + 1); return cargo::success; } @@ -728,7 +728,7 @@ class small_vector { if (auto error = extend(1)) { return error; } - new (End) value_type(std::forward(args)...); + new (static_cast(End)) value_type(std::forward(args)...); setEnd(End + 1); return cargo::success; } @@ -759,7 +759,7 @@ class small_vector { } if (size < count) { std::for_each(End, Begin + count, [](reference item) { - new (std::addressof(item)) value_type(); + new (static_cast(std::addressof(item))) value_type(); }); } End = Begin + count; diff --git a/modules/cargo/include/cargo/string_view.h b/modules/cargo/include/cargo/string_view.h index 308703405..25fe52537 100644 --- a/modules/cargo/include/cargo/string_view.h +++ b/modules/cargo/include/cargo/string_view.h @@ -314,7 +314,7 @@ class string_view { auto comp = traits_type::compare(begin(), view.begin(), std::min(size(), view.size())); if (0 == comp) { - comp = size() == view.size() ? 0 : size() < view.size() ? -1 : 1; + comp = (size() > view.size()) - (size() < view.size()); } return comp; } @@ -953,7 +953,7 @@ inline std::ostream &operator<<(std::ostream &stream, namespace std { template <> struct hash { - inline size_t operator()(const cargo::string_view &sv) const { + size_t operator()(const cargo::string_view &sv) const { // FNV-1a hash if (sizeof(size_t) == 8) { const uint64_t basis{14695981039346656037ULL}; diff --git a/modules/cargo/test/allocator.cpp b/modules/cargo/test/allocator.cpp index 3c14839e0..cc0091672 100644 --- a/modules/cargo/test/allocator.cpp +++ b/modules/cargo/test/allocator.cpp @@ -21,7 +21,7 @@ namespace { struct RootType { - virtual ~RootType(){}; + virtual ~RootType() {}; }; struct LeafType : public RootType { diff --git a/modules/cargo/test/error.cpp b/modules/cargo/test/error.cpp index 6d29c7719..ba6c7e157 100644 --- a/modules/cargo/test/error.cpp +++ b/modules/cargo/test/error.cpp @@ -94,7 +94,7 @@ TEST(error_or, construct_copy_ref) { cargo::error_or eo(42); ASSERT_TRUE(bool(eo)); ASSERT_EQ(42, eo->get()); - cargo::error_or c(eo); + const cargo::error_or &c(eo); ASSERT_TRUE(bool(c)); ASSERT_EQ(42, c->get()); } @@ -104,7 +104,7 @@ TEST(error_or, construct_copy_const_ref) { ASSERT_TRUE(bool(eo)); ASSERT_EQ(42, eo->get()); const cargo::error_or &ref = eo; - cargo::error_or c(ref); + const cargo::error_or &c(ref); ASSERT_TRUE(bool(c)); ASSERT_EQ(42, c->get()); } diff --git a/modules/cargo/test/expected.cpp b/modules/cargo/test/expected.cpp index 052ef6580..523a37c74 100644 --- a/modules/cargo/test/expected.cpp +++ b/modules/cargo/test/expected.cpp @@ -896,19 +896,21 @@ TEST(expected, map_error_callable_with_expected_type) { res.map_error([](F) {}); } -cargo::expected getInt3(int val) { return val; } +static cargo::expected getInt3(int val) { return val; } -cargo::expected getInt2(int val) { return val; } +static cargo::expected getInt2(int val) { return val; } -cargo::expected getInt1() { +static cargo::expected getInt1() { return getInt2(5).and_then(getInt3); } TEST(expected, and_then_std_string) { getInt1(); } -cargo::expected operation1() { return 42; } +static cargo::expected operation1() { return 42; } -cargo::expected operation2(const int) { return "Bananas"; } +static cargo::expected operation2(const int) { + return "Bananas"; +} TEST(expected, and_then_non_constexpr) { const auto intermediate_result = operation1(); diff --git a/modules/cargo/test/optional.cpp b/modules/cargo/test/optional.cpp index dee78dde1..e44c604da 100644 --- a/modules/cargo/test/optional.cpp +++ b/modules/cargo/test/optional.cpp @@ -92,7 +92,7 @@ TEST(optional, bases_triviality) { { struct T { T(const T &) {} - T(T &&){}; + T(T &&) {}; T &operator=(const T &) { return *this; } T &operator=(T &&) { return *this; }; ~T() {} @@ -238,8 +238,8 @@ TEST(optional, constructors) { ASSERT_EQ(*o10, 42); } -constexpr int get_int(int) { return 42; } -constexpr cargo::optional get_opt_int(int) { return 42; } +static constexpr int get_int(int) { return 42; } +static constexpr cargo::optional get_opt_int(int) { return 42; } TEST(optional, map) { // lhs is empty diff --git a/modules/compiler/builtins/abacus/generate/abacus_detail_geometric/abacus_detail_geometric.in b/modules/compiler/builtins/abacus/generate/abacus_detail_geometric/abacus_detail_geometric.in index f8952124c..429d200e5 100644 --- a/modules/compiler/builtins/abacus/generate/abacus_detail_geometric/abacus_detail_geometric.in +++ b/modules/compiler/builtins/abacus/generate/abacus_detail_geometric/abacus_detail_geometric.in @@ -290,11 +290,12 @@ T normalize(T p) { // occur, and try to scale p so that its largest element will have that // exponent. constexpr ElementType max = TypeTraits::max(); - constexpr ElementType elem_upper_limit = - sizeof(ElementType) == 2 ? 0x1.ffcp6 - : sizeof(ElementType) == 4 ? 0x1.fffffep62 - : sizeof(ElementType) == 8 ? 0x1.fffffffffffffp510 - : max; + constexpr ElementType elem_upper_limit = []() -> ElementType { + if (sizeof(ElementType) == 2) return 0x1.ffcp6; + if (sizeof(ElementType) == 4) return 0x1.fffffep62; + if (sizeof(ElementType) == 8) return 0x1.fffffffffffffp510; + return max; + }(); static_assert(elem_upper_limit * elem_upper_limit * num_elements <= max); const ScalarUnsignedType max_au = detail::cast::as(max); diff --git a/modules/compiler/builtins/abacus/generate/abacus_type_traits/shape.in b/modules/compiler/builtins/abacus/generate/abacus_type_traits/shape.in index d0af4ae92..cac28522c 100644 --- a/modules/compiler/builtins/abacus/generate/abacus_type_traits/shape.in +++ b/modules/compiler/builtins/abacus/generate/abacus_type_traits/shape.in @@ -3,24 +3,24 @@ template struct FPShape final { typedef TypeTraits::UnsignedType ScalarUnsignedType; - static constexpr inline ScalarUnsignedType Mantissa() { return @mantissa_bits@; } - static constexpr inline ScalarUnsignedType Exponent() { return @exponent_bits@; } - static constexpr inline ScalarUnsignedType Sign() { return 1; } - static constexpr inline ScalarUnsignedType Bias() { return @exponent_bias@; } + static constexpr ScalarUnsignedType Mantissa() { return @mantissa_bits@; } + static constexpr ScalarUnsignedType Exponent() { return @exponent_bits@; } + static constexpr ScalarUnsignedType Sign() { return 1; } + static constexpr ScalarUnsignedType Bias() { return @exponent_bias@; } - static constexpr inline ScalarUnsignedType NumBits() { return @mantissa_bits@ + @exponent_bits@ + 1; } + static constexpr ScalarUnsignedType NumBits() { return @mantissa_bits@ + @exponent_bits@ + 1; } - static constexpr inline ScalarUnsignedType MantissaMask() { return @mantissa_mask@; } - static constexpr inline ScalarUnsignedType ExponentMask() { return @exponent_mask@; } - static constexpr inline ScalarUnsignedType SignMask() { return @sign_mask@; } - static constexpr inline ScalarUnsignedType InverseSignMask() { return @inv_sign_mask@; } - static constexpr inline ScalarUnsignedType LeastSignificantExponentBit() { return @ls_exp_bit@; } + static constexpr ScalarUnsignedType MantissaMask() { return @mantissa_mask@; } + static constexpr ScalarUnsignedType ExponentMask() { return @exponent_mask@; } + static constexpr ScalarUnsignedType SignMask() { return @sign_mask@; } + static constexpr ScalarUnsignedType InverseSignMask() { return @inv_sign_mask@; } + static constexpr ScalarUnsignedType LeastSignificantExponentBit() { return @ls_exp_bit@; } - static constexpr inline abacus_@type@ ZERO() { return @zero@; } - static constexpr inline ScalarUnsignedType ZeroPointFive() { return @zero_point_five@; } - static constexpr inline ScalarUnsignedType ONE() { return 1u; } - static constexpr inline ScalarUnsignedType ExponentOnes() { return @exponent_ones@; } - static constexpr inline ScalarUnsignedType MantissaOnes() { return @mantissa_mask@; } - static constexpr inline T NaN() { return @nan@; } + static constexpr abacus_@type@ ZERO() { return @zero@; } + static constexpr ScalarUnsignedType ZeroPointFive() { return @zero_point_five@; } + static constexpr ScalarUnsignedType ONE() { return 1u; } + static constexpr ScalarUnsignedType ExponentOnes() { return @exponent_ones@; } + static constexpr ScalarUnsignedType MantissaOnes() { return @mantissa_mask@; } + static constexpr T NaN() { return @nan@; } }; @type_guard_end@ diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/exp_unsafe.h b/modules/compiler/builtins/abacus/include/abacus/internal/exp_unsafe.h index 1f1c90578..fefd82b7f 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/exp_unsafe.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/exp_unsafe.h @@ -75,7 +75,7 @@ struct exp_unsafe_helper { // 0.5f is just to force k into the range [-0.5f, 0.5f] const typename TypeTraits::SignedType k = - abacus::internal::floor_unsafe(x * ln2rcp + 0.5f); + abacus::internal::floor_unsafe((x * ln2rcp) + 0.5f); const T kf = abacus::detail::cast::convert(k); const T r = (x - (codyWaite1 * kf)) - (codyWaite2 * kf); @@ -108,7 +108,7 @@ struct exp_unsafe_helper { const typename TypeTraits::SignedType k = abacus::internal::floor_unsafe(x * ln2rcp); const T kf = abacus::detail::cast::convert(k); - const T r = ((x - kf * codyWaite1) - kf * codyWaite2) - kf * codyWaite3; + const T r = ((x - kf * codyWaite1) - kf * codyWaite2) - (kf * codyWaite3); const abacus_double polynomial[15] = {0.100000000000000000004072260342e1, 0.999999999999999979186940414675e0, diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/fma.h b/modules/compiler/builtins/abacus/include/abacus/internal/fma.h new file mode 100644 index 000000000..74e8cccc3 --- /dev/null +++ b/modules/compiler/builtins/abacus/include/abacus/internal/fma.h @@ -0,0 +1,29 @@ +// Copyright (C) Codeplay Software Limited +// +// Licensed under the Apache License, Version 2.0 (the "License") with LLVM +// Exceptions; you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. +// +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef __ABACUS_INTERNAL_FMA_H__ +#define __ABACUS_INTERNAL_FMA_H__ + +#include + +namespace abacus { +namespace internal { +template +void inplace_fma(T &, T &, T &); +} // namespace internal +} // namespace abacus + +#endif //__ABACUS_INTERNAL_FMA_H__ diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/fmod_unsafe.h b/modules/compiler/builtins/abacus/include/abacus/internal/fmod_unsafe.h index 0b85bd87f..45679b18f 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/fmod_unsafe.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/fmod_unsafe.h @@ -97,7 +97,7 @@ struct fmod_helper { const SLongType cond = i >= loop_info::shift; const ULongType temp = ansMant << loop_info::shift; const ULongType r = temp / mMantFudged; - ansMant = __abacus_select(ansMant, temp - r * mMantFudged, cond); + ansMant = __abacus_select(ansMant, temp - (r * mMantFudged), cond); quotient = __abacus_select(quotient, (quotient << loop_info::shift) + r, cond); i = __abacus_select(i, i - loop_info::shift, cond); diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/lgamma_positive.h b/modules/compiler/builtins/abacus/include/abacus/internal/lgamma_positive.h index ebf2591a5..797902825 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/lgamma_positive.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/lgamma_positive.h @@ -149,13 +149,13 @@ inline abacus_float lgamma_positive(abacus_float x) { (0.08333333333f / x + 0.91893851757049560546875f)); } const abacus_int high_four = 4 * (x > _intervals[4]); - const abacus_int high_two = high_four + 2 * (x > _intervals[high_four + 2]); + const abacus_int high_two = high_four + (2 * (x > _intervals[high_four + 2])); const abacus_int interval = high_two + (x > _intervals[high_two + 1]); x -= _lgamma_translation[interval]; const abacus_float semi = abacus::internal::horner_polynomial( - x, __codeplay_lgamma_positive_coeff + interval * (size_t)8, 8); + x, __codeplay_lgamma_positive_coeff + (interval * (size_t)8), 8); return (interval) ? semi : semi - logx; } @@ -177,7 +177,7 @@ inline T lgamma_positive(const T &x) { const T poly = abacus::internal::horner_polynomial( x - _lgamma_translation[i], - __codeplay_lgamma_positive_coeff + i * (size_t)8, 8); + __codeplay_lgamma_positive_coeff + (i * (size_t)8), 8); ans = __abacus_select(ans, poly, cond); } @@ -267,26 +267,27 @@ inline abacus_double lgamma_1to2(abacus_double x) { // in this large expression. const abacus_double poly = -0.577215664901532860606399608944e0 + - (0.822467033424113218033719309828e0 + - (-0.400685634386531367842803708273e0 + - (0.270580808427777333564177283854e0 + - (-0.207385551028218933790777990141e0 + - (0.169557176979815554158924679926e0 + - (-0.144049896314135072037356804522e0 + - (0.125509661206761405444719466196e0 + - (-0.111334153842271144222894568402e0 + - (0.100098314838956727346418246624e0 + - (-0.909450071440206661576973282302e-1 + - (0.832980965196954546433547142618e-1 + - (-0.766590205621694453623593115599e-1 + - (0.703610686487618231366489543360e-1 + - (-0.632970018535340529257608896951e-1 + - (0.539613915512959858827812080122e-1 + - (-0.413575207389668799045096002923e-1 + - (0.265466543807868911939220884698e-1 + - (-0.130043694118914474315358017838e-1 + - (0.422529901859797520291282888992e-2 - - 0.672121132329985303236139757800e-3 * x) * + ((0.822467033424113218033719309828e0 + + (-0.400685634386531367842803708273e0 + + (0.270580808427777333564177283854e0 + + (-0.207385551028218933790777990141e0 + + (0.169557176979815554158924679926e0 + + (-0.144049896314135072037356804522e0 + + (0.125509661206761405444719466196e0 + + (-0.111334153842271144222894568402e0 + + (0.100098314838956727346418246624e0 + + (-0.909450071440206661576973282302e-1 + + (0.832980965196954546433547142618e-1 + + (-0.766590205621694453623593115599e-1 + + (0.703610686487618231366489543360e-1 + + (-0.632970018535340529257608896951e-1 + + (0.539613915512959858827812080122e-1 + + (-0.413575207389668799045096002923e-1 + + (0.265466543807868911939220884698e-1 + + (-0.130043694118914474315358017838e-1 + + (0.422529901859797520291282888992e-2 - + 0.672121132329985303236139757800e-3 * x) * + x) * x) * x) * x) * @@ -304,8 +305,7 @@ inline abacus_double lgamma_1to2(abacus_double x) { x) * x) * x) * - x) * - x; + x); ans = poly * x; } @@ -314,26 +314,27 @@ inline abacus_double lgamma_1to2(abacus_double x) { x = 2.0 - x; const abacus_double poly = -0.422784335098467139393487866219e0 + - (0.322467033424113218236131449144e0 + - (0.673523010531980951553028283174e-1 + - (0.205808084277845453409081136005e-1 + - (0.738555102867413988255202865380e-2 + - (0.289051033073576068020666031208e-2 + - (0.119275391184648988863776614656e-2 + - (0.509669522231860084260680834947e-3 + - (0.223154790728439308838879178915e-3 + - (0.994572003976975949284111902962e-4 + - (0.44928556849107108509758914903e-4 + - (0.204938234555901374791249695625e-4 + - (0.94999652296367022403396210220e-5 + - (0.41605582240358196374085008100e-5 + - (0.26334418813466617407682748547e-5 + - (-0.3230790013731150352208783542e-6 + - (0.254758976379121405515527436892e-5 + - (-0.234350817628823776555608301853e-5 + - (0.229896826274862502096007889899e-5 + - (-0.116894305652024296372739243535e-5 + - 0.367605658911627977263759472550e-6 * x) * + ((0.322467033424113218236131449144e0 + + (0.673523010531980951553028283174e-1 + + (0.205808084277845453409081136005e-1 + + (0.738555102867413988255202865380e-2 + + (0.289051033073576068020666031208e-2 + + (0.119275391184648988863776614656e-2 + + (0.509669522231860084260680834947e-3 + + (0.223154790728439308838879178915e-3 + + (0.994572003976975949284111902962e-4 + + (0.44928556849107108509758914903e-4 + + (0.204938234555901374791249695625e-4 + + (0.94999652296367022403396210220e-5 + + (0.41605582240358196374085008100e-5 + + (0.26334418813466617407682748547e-5 + + (-0.3230790013731150352208783542e-6 + + (0.254758976379121405515527436892e-5 + + (-0.234350817628823776555608301853e-5 + + (0.229896826274862502096007889899e-5 + + (-0.116894305652024296372739243535e-5 + + 0.367605658911627977263759472550e-6 * x) * + x) * x) * x) * x) * @@ -351,8 +352,7 @@ inline abacus_double lgamma_1to2(abacus_double x) { x) * x) * x) * - x) * - x; + x); ans = poly * x; } @@ -369,9 +369,9 @@ inline abacus_double lgamma_positive(abacus_double x) { const abacus_double ln2pi = 1.837877066409345483560659472811235279722794947275566825634303 * 0.5; const abacus_double xx = x * x; - return (x - 0.5) * __abacus_log(x) - x + ln2pi + - ((((6930.0 * xx - 231.0) * xx + 66.0) * xx - 49.5) * xx + 70.0) / - (83160.0 * xx * xx * xx * xx * x); + return ((x - 0.5) * __abacus_log(x)) - x + ln2pi + + (((((6930.0 * xx - 231.0) * xx + 66.0) * xx - 49.5) * xx + 70.0) / + (83160.0 * xx * xx * xx * xx * x)); } // G(x) = G(x+1) - ln(x) @@ -427,26 +427,27 @@ inline abacus_double lgamma_positive(abacus_double x) { if (4.0 < x && x < 10.0) { x -= 5.0; return 0.317805383034794379153748384411e1 + - (0.150611766843180065206245208226e1 + - (0.110661477868644201072990211035e0 + - (-0.813162204086589076485758012768e-2 + - (0.892826174031926137374888255900e-3 + - (-0.117193260841602955724637693181e-3 + - (0.170298763235858759482598081220e-4 + - (-0.264212384092237999430596483986e-5 + - (0.428950533963169013392955115881e-6 + - (-0.719819512446612410046871622485e-7 + - (0.123861813967482187149578571399e-7 + - (-0.217520395756280036045213062393e-8 + - (0.388781809759014410074807442869e-9 + - (-0.700796265038755490062409794969e-10 + - (0.123354858659154476661143284704e-10 + - (-0.199154720339166450701114580768e-11 + - (0.272324468492957942440892325956e-12 + - (-0.290332466669136911144579608975e-13 + - (0.220377469939621954125626067392e-14 + - (-0.104427587851387682923206247345e-15 + - 0.230360340483404522044679012564e-17 * x) * + ((0.150611766843180065206245208226e1 + + (0.110661477868644201072990211035e0 + + (-0.813162204086589076485758012768e-2 + + (0.892826174031926137374888255900e-3 + + (-0.117193260841602955724637693181e-3 + + (0.170298763235858759482598081220e-4 + + (-0.264212384092237999430596483986e-5 + + (0.428950533963169013392955115881e-6 + + (-0.719819512446612410046871622485e-7 + + (0.123861813967482187149578571399e-7 + + (-0.217520395756280036045213062393e-8 + + (0.388781809759014410074807442869e-9 + + (-0.700796265038755490062409794969e-10 + + (0.123354858659154476661143284704e-10 + + (-0.199154720339166450701114580768e-11 + + (0.272324468492957942440892325956e-12 + + (-0.290332466669136911144579608975e-13 + + (0.220377469939621954125626067392e-14 + + (-0.104427587851387682923206247345e-15 + + 0.230360340483404522044679012564e-17 * x) * + x) * x) * x) * x) * @@ -464,8 +465,7 @@ inline abacus_double lgamma_positive(abacus_double x) { x) * x) * x) * - x) * - x; + x); } // Now we merely need a way to calculate Gamma(x) from [4 , 1.0e6] diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact.h b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact.h index 0f977ebbe..2ba7daa6a 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact.h @@ -43,7 +43,7 @@ struct multiply_exact_helper { // shift is the number of mantissa bits plus 1 for the implicit bit, then // divided by two as we're splitting `x` into two parts, rounded up as // described in section 6.3 with reference to 5.7. - const SignedType shift = FPShape::Mantissa() / 2 + 1; + const SignedType shift = (FPShape::Mantissa() / 2) + 1; C = (C << shift) + 1; const T gamma = x * abacus::detail::cast::convert(C); const T delta = x - gamma; @@ -96,9 +96,9 @@ inline T multiply_exact(const T x, const T y, T *out_remainder) { multiply_exact_helper::split(y, &y_hi, &y_lo); const T r1 = x * y; - const T t1 = -r1 + x_hi * y_hi; - const T t2 = t1 + x_hi * y_lo; - const T t3 = t2 + x_lo * y_hi; + const T t1 = -r1 + (x_hi * y_hi); + const T t2 = t1 + (x_hi * y_lo); + const T t3 = t2 + (x_lo * y_hi); *out_remainder = t3 + x_lo * y_lo; return r1; diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact_unsafe.h b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact_unsafe.h index bc4175e2f..0305d6884 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact_unsafe.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_exact_unsafe.h @@ -60,9 +60,9 @@ inline T multiply_exact_unsafe(const T x, const T y, T *out_remainder) { const T y_lo = y - y_hi; const T r1 = x * y; - const T t1 = -r1 + x_hi * y_hi; - const T t2 = t1 + x_hi * y_lo; - const T t3 = t2 + x_lo * y_hi; + const T t1 = -r1 + (x_hi * y_hi); + const T t2 = t1 + (x_hi * y_lo); + const T t3 = t2 + (x_lo * y_hi); *out_remainder = t3 + x_lo * y_lo; return r1; diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_extended_precision.h b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_extended_precision.h index be596c381..4c04718b7 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/multiply_extended_precision.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/multiply_extended_precision.h @@ -58,7 +58,7 @@ inline T multiply_extended_precision( abacus::internal::add_exact<>(term1_hi, term1_lo, &more_sum_lo); const T half_sum = (more_sum_lo + term2_lo) + - abacus::detail::cast::convert(n) * high_sum_lo; + (abacus::detail::cast::convert(n) * high_sum_lo); T final_sum_lo; const T final_sum_hi = diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/payne_hanek.h b/modules/compiler/builtins/abacus/include/abacus/internal/payne_hanek.h index 9e226b141..4bb88716f 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/payne_hanek.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/payne_hanek.h @@ -478,7 +478,7 @@ inline T tan_naive_reduction(T x, typename TypeTraits::SignedType *octet) { // Cody & Waite subtraction method. const T cw = ((xAbs - foctet * PI_OVER_FOUR_C0) - foctet * PI_OVER_FOUR_C1) - - foctet * PI_OVER_FOUR_C2; + (foctet * PI_OVER_FOUR_C2); return __abacus_fabs(cw); } diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/pow_unsafe.h b/modules/compiler/builtins/abacus/include/abacus/internal/pow_unsafe.h index dc83942c7..e241bbae2 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/pow_unsafe.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/pow_unsafe.h @@ -326,9 +326,9 @@ struct pow_unsafe_helper { exponent_floor += mantissa_trunc; exponent_mantissa -= abacus::detail::cast::convert(mantissa_trunc); - T result = (T)1.0 + exponent_mantissa * abacus::internal::horner_polynomial( - exponent_mantissa, - __codeplay_pow_unsafe_coeffD); + T result = (T)1.0 + (exponent_mantissa * + abacus::internal::horner_polynomial( + exponent_mantissa, __codeplay_pow_unsafe_coeffD)); result = __abacus_ldexp( result, abacus::detail::cast::convert(exponent_floor)); diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/rsqrt_unsafe.h b/modules/compiler/builtins/abacus/include/abacus/internal/rsqrt_unsafe.h index 6b171cfe5..a00a1817e 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/rsqrt_unsafe.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/rsqrt_unsafe.h @@ -41,7 +41,7 @@ inline T rsqrt_unsafe(const T &x, unsigned newton_raphson_iterations) { template struct rsqrt_unsafe_helper { template - inline static T2 _(const T2 &x) { + static T2 _(const T2 &x) { // N == 3 for float, N == 6 for double // Approximate 1/sqrt(x) const unsigned s = sizeof(typename TypeTraits::ElementType); diff --git a/modules/compiler/builtins/abacus/include/abacus/internal/sqrt.h b/modules/compiler/builtins/abacus/include/abacus/internal/sqrt.h index e4865ec27..1dd93aac1 100644 --- a/modules/compiler/builtins/abacus/include/abacus/internal/sqrt.h +++ b/modules/compiler/builtins/abacus/include/abacus/internal/sqrt.h @@ -21,6 +21,9 @@ namespace abacus { namespace internal { +template +void inplace_sqrt(T &); + template T sqrt(T); } // namespace internal diff --git a/modules/compiler/builtins/abacus/source/abacus_extra/normalizers.cpp b/modules/compiler/builtins/abacus/source/abacus_extra/normalizers.cpp index 945c06944..ab225b030 100644 --- a/modules/compiler/builtins/abacus/source/abacus_extra/normalizers.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_extra/normalizers.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/compiler/builtins/abacus/source/abacus_extra/reflect.cpp b/modules/compiler/builtins/abacus/source/abacus_extra/reflect.cpp index cf7257662..f3e143818 100644 --- a/modules/compiler/builtins/abacus/source/abacus_extra/reflect.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_extra/reflect.cpp @@ -21,7 +21,7 @@ namespace { template T reflect(const T i, const T n) { - return i - n * __abacus_dot(i, n) * 2; + return i - (n * __abacus_dot(i, n) * 2); } } // namespace diff --git a/modules/compiler/builtins/abacus/source/abacus_extra/refract.cpp b/modules/compiler/builtins/abacus/source/abacus_extra/refract.cpp index 2065d6e58..de7f4a6a6 100644 --- a/modules/compiler/builtins/abacus/source/abacus_extra/refract.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_extra/refract.cpp @@ -27,7 +27,7 @@ T refract(const T i, const T n, const U eta) { typedef typename TypeTraits::ElementType ElementType; const ElementType intermediate = __abacus_dot(n, i); - const ElementType k = 1 - eta * eta * (1 - intermediate * intermediate); + const ElementType k = 1 - (eta * eta * (1 - intermediate * intermediate)); const T result = (i * eta) - (n * (eta * intermediate + __abacus_sqrt(k))); diff --git a/modules/compiler/builtins/abacus/source/abacus_integer/mad_sat.cpp b/modules/compiler/builtins/abacus/source/abacus_integer/mad_sat.cpp index f1c749171..8655e028c 100644 --- a/modules/compiler/builtins/abacus/source/abacus_integer/mad_sat.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_integer/mad_sat.cpp @@ -27,7 +27,7 @@ T mad_sat(const T x, const T y, const T z) { const LargerType bX = abacus::detail::cast::convert(x); const LargerType bY = abacus::detail::cast::convert(y); const LargerType bZ = abacus::detail::cast::convert(z); - const LargerType bR = bX * bY + bZ; + const LargerType bR = (bX * bY) + bZ; return abacus::detail::cast::convert( __abacus_clamp(bR, abacus::detail::cast::convert( diff --git a/modules/compiler/builtins/abacus/source/abacus_math/acos.cpp b/modules/compiler/builtins/abacus/source/abacus_math/acos.cpp index 13c52ca2a..99273b661 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/acos.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/acos.cpp @@ -129,7 +129,7 @@ abacus_float ABACUS_API __abacus_acos(abacus_float x) { __Codeplay__estrin_4coeff(xAbs, polynomial + interval * (size_t)4); #else const abacus_float ans = abacus::internal::horner_polynomial( - xAbs, polynomial + interval * (size_t)4, 4); + xAbs, polynomial + (interval * (size_t)4), 4); #endif // get acos: @@ -158,7 +158,7 @@ T acos(const T x) { interval = __abacus_select(interval, i, cond); const T poly = abacus::internal::horner_polynomial( - i < 12 ? oneMinusXAbs : xAbs, polynomial + i * (size_t)4, 4); + i < 12 ? oneMinusXAbs : xAbs, polynomial + (i * (size_t)4), 4); ans = __abacus_select(ans, poly, cond); } diff --git a/modules/compiler/builtins/abacus/source/abacus_math/asin.cpp b/modules/compiler/builtins/abacus/source/abacus_math/asin.cpp index 0e663aeaf..9d7af3ab8 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/asin.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/asin.cpp @@ -134,7 +134,7 @@ abacus_float ABACUS_API __abacus_asin(abacus_float x) { __codeplay_asin_coeff + interval * (size_t)5); #else ans = abacus::internal::horner_polynomial( - ans, __codeplay_asin_coeff + interval * (size_t)5, 5); + ans, __codeplay_asin_coeff + (interval * (size_t)5), 5); #endif if (interval < 9) { @@ -230,7 +230,8 @@ T asin(const T x) { interval = __abacus_select(interval, i, cond); const T poly = abacus::internal::horner_polynomial( - i < 9 ? oneMinusXAbs : xAbs, __codeplay_asin_coeff + i * (size_t)5, 5); + i < 9 ? oneMinusXAbs : xAbs, __codeplay_asin_coeff + (i * (size_t)5), + 5); ans = __abacus_select(ans, poly, cond); } diff --git a/modules/compiler/builtins/abacus/source/abacus_math/asinh.cpp b/modules/compiler/builtins/abacus/source/abacus_math/asinh.cpp index 7d2fc8865..201a3ea2c 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/asinh.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/asinh.cpp @@ -144,7 +144,7 @@ abacus_float ABACUS_API __abacus_asinh(abacus_float x) { high_two + ((xAbs < intervals[high_two + 1]) ? 1 : 0); abacus_float ans = abacus::internal::horner_polynomial( - xAbs, __codeplay_asinh_coeff + interval * (size_t)5, 5); + xAbs, __codeplay_asinh_coeff + (interval * (size_t)5), 5); if (interval < 11) { ans = __abacus_log1p(ans); @@ -175,7 +175,7 @@ T asinh(const T x) { interval = __abacus_select(interval, i, cond); const T poly = abacus::internal::horner_polynomial( - xAbs, __codeplay_asinh_coeff + i * (size_t)5, 5); + xAbs, __codeplay_asinh_coeff + (i * (size_t)5), 5); ans = __abacus_select(ans, poly, cond); } diff --git a/modules/compiler/builtins/abacus/source/abacus_math/cbrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/cbrt.cpp index 73d8fe6bd..2dc7aaccf 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/cbrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/cbrt.cpp @@ -150,7 +150,7 @@ struct helper { // Get a good initial guess for cbrt (using some magic!) // 0x2a517d3c == (2.0/3.0) * 2^23 * (127 - 0.0450465) const T initialGuess = abacus::detail::cast::as( - abacus::detail::cast::as(xReduced) / 3 + 0x2a517d3c); + (abacus::detail::cast::as(xReduced) / 3) + 0x2a517d3c); // one iteration of Newton-Raphson const T guessSqr = initialGuess * initialGuess; @@ -206,7 +206,7 @@ struct helper { // force expRemainder to always end up being positive expAns = __abacus_select(expAns, expAns - 1, xExp < 0); - const IntType expRemainder = xExp - expAns * 3; + const IntType expRemainder = xExp - (expAns * 3); const abacus_double polynomial[11] = { 0.3016866403890285027141003e0, 0.2136093385352237667433857e1, diff --git a/modules/compiler/builtins/abacus/source/abacus_math/exp10.cpp b/modules/compiler/builtins/abacus/source/abacus_math/exp10.cpp index fe25f46cd..0e8478aee 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/exp10.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/exp10.cpp @@ -96,7 +96,7 @@ struct helper { // 0.5f is just to force k into the range [-0.5f, 0.5f] const SignedType k = - (abacus::internal::floor_unsafe(x * log10_2rcp + 0.5f)); + (abacus::internal::floor_unsafe((x * log10_2rcp) + 0.5f)); const T kf = abacus::detail::cast::convert(k); const T r = (x - (kf * codyWaite1)) - (kf * codyWaite2); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/fabs.cpp b/modules/compiler/builtins/abacus/source/abacus_math/fabs.cpp index 682e050f5..3b88df900 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/fabs.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/fabs.cpp @@ -16,6 +16,7 @@ #include #include +#include namespace { template ::ElementType> diff --git a/modules/compiler/builtins/abacus/source/abacus_math/fdim.cpp b/modules/compiler/builtins/abacus/source/abacus_math/fdim.cpp index d301de832..75deee382 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/fdim.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/fdim.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include diff --git a/modules/compiler/builtins/abacus/source/abacus_math/fma.cpp b/modules/compiler/builtins/abacus/source/abacus_math/fma.cpp index 43c184e0f..5e8879ccd 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/fma.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/fma.cpp @@ -15,21 +15,15 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include +#include -namespace abacus { -namespace detail { template -void inplace_fma(T &, T &, T &); -} // namespace detail -} // namespace abacus - -namespace { -template -inline T fma_helper(T x, T y, T z) { - abacus::detail::inplace_fma(x, y, z); +static inline T fma_helper(T x, T y, T z) { + abacus::internal::inplace_fma(x, y, z); return x; } -} // namespace + #ifdef __CA_BUILTINS_HALF_SUPPORT abacus_half ABACUS_API __abacus_fma(abacus_half x, abacus_half y, abacus_half z) { diff --git a/modules/compiler/builtins/abacus/source/abacus_math/frexp.cpp b/modules/compiler/builtins/abacus/source/abacus_math/frexp.cpp index ee1678b74..fac274598 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/frexp.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/frexp.cpp @@ -48,11 +48,9 @@ struct MagicNumbers {}; */ template <> struct MagicNumbers { - static inline constexpr abacus_float Coeficent() { return 3.3554432e7f; } - static inline constexpr abacus_float Subtraction() { - return 3.944304526105059E-31f; - } - static inline constexpr abacus_int MultiplicationFactor() { return 25; } + static constexpr abacus_float Coeficent() { return 3.3554432e7f; } + static constexpr abacus_float Subtraction() { return 3.944304526105059E-31f; } + static constexpr abacus_int MultiplicationFactor() { return 25; } }; // Original comment: @@ -73,13 +71,11 @@ struct MagicNumbers { #ifdef __CA_BUILTINS_DOUBLE_SUPPORT template <> struct MagicNumbers { - static inline constexpr abacus_double Coeficent() { - return 1.8014398509481984e16; - } - static inline constexpr abacus_double Subtraction() { + static constexpr abacus_double Coeficent() { return 1.8014398509481984e16; } + static constexpr abacus_double Subtraction() { return 4.008336720017945555992216102695993318699958272e-292; } - static inline constexpr abacus_int MultiplicationFactor() { return 54; } + static constexpr abacus_int MultiplicationFactor() { return 54; } }; #endif // __CA_BUILTINS_DOUBLE_SUPPORT @@ -117,7 +113,7 @@ T frexp_denorm_multiplier(const T x) { const T xAbsPlusHidden = abacus::detail::cast::as(xAbsOrHidden); - const T result = xAbsPlusHidden * MagicNumbers::Coeficent() - + const T result = (xAbsPlusHidden * MagicNumbers::Coeficent()) - MagicNumbers::Subtraction(); return __abacus_copysign(result, x); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/half_rsqrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/half_rsqrt.cpp index f4eea32ed..d46205588 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/half_rsqrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/half_rsqrt.cpp @@ -50,7 +50,7 @@ T half_rsqrt(const T x) { // (x * 2^24) T processedX = __abacus_select( x, - abacus::detail::cast::as(xUint | F_HIDDEN_BIT) * 16777216.0f - + (abacus::detail::cast::as(xUint | F_HIDDEN_BIT) * 16777216.0f) - __abacus_as_float(0x0C800000), xSmall); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/half_sqrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/half_sqrt.cpp index 5051b613d..f574c3610 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/half_sqrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/half_sqrt.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include abacus_float ABACUS_API __abacus_half_sqrt(abacus_float x) { diff --git a/modules/compiler/builtins/abacus/source/abacus_math/half_tan.cpp b/modules/compiler/builtins/abacus/source/abacus_math/half_tan.cpp index 2844a04d2..80dab61bf 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/half_tan.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/half_tan.cpp @@ -31,7 +31,7 @@ T half_tan(const T x) { T xSquared = xReduced * xReduced; T tan_numerator = ((T)1.157866227f - (T)0.07954878635f * xSquared) * xReduced; - T tan_denominator = ((T)1.157857119f - (T).4652878584f * xSquared); + T tan_denominator = ((T)1.157857119f - ((T).4652878584f * xSquared)); octet = octet & 0x3; diff --git a/modules/compiler/builtins/abacus/source/abacus_math/hypot.cpp b/modules/compiler/builtins/abacus/source/abacus_math/hypot.cpp index cd09a12c9..2f17645cb 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/hypot.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/hypot.cpp @@ -35,7 +35,7 @@ struct hypot_helper { using SignedType = typename TypeTraits::SignedType; using UnsignedType = typename TypeTraits::UnsignedType; - inline static T _(const T x, const T y) { + static T _(const T x, const T y) { const T xAbs = __abacus_fabs(x); const T yAbs = __abacus_fabs(y); @@ -45,7 +45,7 @@ struct hypot_helper { const T part = lo / hi; - const T part2 = part * part + 1.0f; + const T part2 = (part * part) + 1.0f; // See rsqrt.cpp for documentation on this bound and the scaling // done before calling rqsrt_unsafe(). diff --git a/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.cpp b/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.cpp index 3072cfbb3..a31998a95 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.cpp @@ -16,11 +16,12 @@ #include #include +#include #include namespace abacus { -namespace detail { +namespace internal { template void inplace_fma(T &a, T &b, T &c) { using ET = typename TypeTraits::ElementType; @@ -30,48 +31,49 @@ void inplace_fma(T &a, T &b, T &c) { *p = std::fma(*p, *q, *r); } } -} // namespace detail +} // namespace internal } // namespace abacus #ifdef __CA_BUILTINS_HALF_SUPPORT -template void abacus::detail::inplace_fma(abacus_half &, abacus_half &, - abacus_half &); -template void abacus::detail::inplace_fma(abacus_half2 &, abacus_half2 &, - abacus_half2 &); -template void abacus::detail::inplace_fma(abacus_half3 &, abacus_half3 &, - abacus_half3 &); -template void abacus::detail::inplace_fma(abacus_half4 &, abacus_half4 &, - abacus_half4 &); -template void abacus::detail::inplace_fma(abacus_half8 &, abacus_half8 &, - abacus_half8 &); -template void abacus::detail::inplace_fma(abacus_half16 &, abacus_half16 &, - abacus_half16 &); +template void abacus::internal::inplace_fma(abacus_half &, abacus_half &, + abacus_half &); +template void abacus::internal::inplace_fma(abacus_half2 &, abacus_half2 &, + abacus_half2 &); +template void abacus::internal::inplace_fma(abacus_half3 &, abacus_half3 &, + abacus_half3 &); +template void abacus::internal::inplace_fma(abacus_half4 &, abacus_half4 &, + abacus_half4 &); +template void abacus::internal::inplace_fma(abacus_half8 &, abacus_half8 &, + abacus_half8 &); +template void abacus::internal::inplace_fma(abacus_half16 &, abacus_half16 &, + abacus_half16 &); #endif // __CA_BUILTINS_HALF_SUPPORT -template void abacus::detail::inplace_fma(abacus_float &, abacus_float &, - abacus_float &); -template void abacus::detail::inplace_fma(abacus_float2 &, abacus_float2 &, - abacus_float2 &); -template void abacus::detail::inplace_fma(abacus_float3 &, abacus_float3 &, - abacus_float3 &); -template void abacus::detail::inplace_fma(abacus_float4 &, abacus_float4 &, - abacus_float4 &); -template void abacus::detail::inplace_fma(abacus_float8 &, abacus_float8 &, - abacus_float8 &); -template void abacus::detail::inplace_fma(abacus_float16 &, abacus_float16 &, - abacus_float16 &); +template void abacus::internal::inplace_fma(abacus_float &, abacus_float &, + abacus_float &); +template void abacus::internal::inplace_fma(abacus_float2 &, abacus_float2 &, + abacus_float2 &); +template void abacus::internal::inplace_fma(abacus_float3 &, abacus_float3 &, + abacus_float3 &); +template void abacus::internal::inplace_fma(abacus_float4 &, abacus_float4 &, + abacus_float4 &); +template void abacus::internal::inplace_fma(abacus_float8 &, abacus_float8 &, + abacus_float8 &); +template void abacus::internal::inplace_fma(abacus_float16 &, abacus_float16 &, + abacus_float16 &); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -template void abacus::detail::inplace_fma(abacus_double &, abacus_double &, - abacus_double &); -template void abacus::detail::inplace_fma(abacus_double2 &, abacus_double2 &, - abacus_double2 &); -template void abacus::detail::inplace_fma(abacus_double3 &, abacus_double3 &, - abacus_double3 &); -template void abacus::detail::inplace_fma(abacus_double4 &, abacus_double4 &, - abacus_double4 &); -template void abacus::detail::inplace_fma(abacus_double8 &, abacus_double8 &, - abacus_double8 &); -template void abacus::detail::inplace_fma(abacus_double16 &, abacus_double16 &, - abacus_double16 &); +template void abacus::internal::inplace_fma(abacus_double &, abacus_double &, + abacus_double &); +template void abacus::internal::inplace_fma(abacus_double2 &, abacus_double2 &, + abacus_double2 &); +template void abacus::internal::inplace_fma(abacus_double3 &, abacus_double3 &, + abacus_double3 &); +template void abacus::internal::inplace_fma(abacus_double4 &, abacus_double4 &, + abacus_double4 &); +template void abacus::internal::inplace_fma(abacus_double8 &, abacus_double8 &, + abacus_double8 &); +template void abacus::internal::inplace_fma(abacus_double16 &, + abacus_double16 &, + abacus_double16 &); #endif // __CA_BUILTINS_DOUBLE_SUPPORT diff --git a/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.ll.in b/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.ll.in index b2c19b220..a04bc2d54 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.ll.in +++ b/modules/compiler/builtins/abacus/source/abacus_math/inplace_fma.ll.in @@ -16,7 +16,7 @@ @target@ -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDF16_EEvRT_S3_S3_(ptr dereferenceable(2) %0, ptr dereferenceable(2) %1, ptr dereferenceable(2) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDF16_EEvRT_S3_S3_(ptr dereferenceable(2) %0, ptr dereferenceable(2) %1, ptr dereferenceable(2) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load half, ptr %0 %4 = load half, ptr %1 @@ -26,7 +26,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv2_DF16_EEvRT_S4_S4_(ptr dereferenceable(4) %0, ptr dereferenceable(4) %1, ptr dereferenceable(4) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv2_DF16_EEvRT_S4_S4_(ptr dereferenceable(4) %0, ptr dereferenceable(4) %1, ptr dereferenceable(4) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <2 x half>, ptr %0 %4 = load <2 x half>, ptr %1 @@ -36,7 +36,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv3_DF16_EEvRT_S4_S4_(ptr dereferenceable(6) %0, ptr dereferenceable(6) %1, ptr dereferenceable(6) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv3_DF16_EEvRT_S4_S4_(ptr dereferenceable(6) %0, ptr dereferenceable(6) %1, ptr dereferenceable(6) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <3 x half>, ptr %0 %4 = load <3 x half>, ptr %1 @@ -46,7 +46,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv4_DF16_EEvRT_S4_S4_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv4_DF16_EEvRT_S4_S4_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <4 x half>, ptr %0 %4 = load <4 x half>, ptr %1 @@ -56,7 +56,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv8_DF16_EEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv8_DF16_EEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <8 x half>, ptr %0 %4 = load <8 x half>, ptr %1 @@ -66,7 +66,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv16_DF16_EEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv16_DF16_EEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <16 x half>, ptr %0 %4 = load <16 x half>, ptr %1 @@ -76,7 +76,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIfEEvRT_S3_S3_(ptr dereferenceable(4) %0, ptr dereferenceable(4) %1, ptr dereferenceable(4) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIfEEvRT_S3_S3_(ptr dereferenceable(4) %0, ptr dereferenceable(4) %1, ptr dereferenceable(4) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load float, ptr %0 %4 = load float, ptr %1 @@ -86,7 +86,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv2_fEEvRT_S4_S4_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv2_fEEvRT_S4_S4_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <2 x float>, ptr %0 %4 = load <2 x float>, ptr %1 @@ -96,7 +96,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv3_fEEvRT_S4_S4_(ptr dereferenceable(12) %0, ptr dereferenceable(12) %1, ptr dereferenceable(12) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv3_fEEvRT_S4_S4_(ptr dereferenceable(12) %0, ptr dereferenceable(12) %1, ptr dereferenceable(12) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <3 x float>, ptr %0 %4 = load <3 x float>, ptr %1 @@ -106,7 +106,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv4_fEEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv4_fEEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <4 x float>, ptr %0 %4 = load <4 x float>, ptr %1 @@ -116,7 +116,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv8_fEEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv8_fEEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <8 x float>, ptr %0 %4 = load <8 x float>, ptr %1 @@ -126,7 +126,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv16_fEEvRT_S4_S4_(ptr dereferenceable(64) %0, ptr dereferenceable(64) %1, ptr dereferenceable(64) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv16_fEEvRT_S4_S4_(ptr dereferenceable(64) %0, ptr dereferenceable(64) %1, ptr dereferenceable(64) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <16 x float>, ptr %0 %4 = load <16 x float>, ptr %1 @@ -136,7 +136,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIdEEvRT_S3_S3_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIdEEvRT_S3_S3_(ptr dereferenceable(8) %0, ptr dereferenceable(8) %1, ptr dereferenceable(8) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load double, ptr %0 %4 = load double, ptr %1 @@ -146,7 +146,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv2_dEEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv2_dEEvRT_S4_S4_(ptr dereferenceable(16) %0, ptr dereferenceable(16) %1, ptr dereferenceable(16) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <2 x double>, ptr %0 %4 = load <2 x double>, ptr %1 @@ -156,7 +156,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv3_dEEvRT_S4_S4_(ptr dereferenceable(24) %0, ptr dereferenceable(24) %1, ptr dereferenceable(24) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv3_dEEvRT_S4_S4_(ptr dereferenceable(24) %0, ptr dereferenceable(24) %1, ptr dereferenceable(24) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <3 x double>, ptr %0 %4 = load <3 x double>, ptr %1 @@ -166,7 +166,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv4_dEEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv4_dEEvRT_S4_S4_(ptr dereferenceable(32) %0, ptr dereferenceable(32) %1, ptr dereferenceable(32) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <4 x double>, ptr %0 %4 = load <4 x double>, ptr %1 @@ -176,7 +176,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv8_dEEvRT_S4_S4_(ptr dereferenceable(64) %0, ptr dereferenceable(64) %1, ptr dereferenceable(64) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv8_dEEvRT_S4_S4_(ptr dereferenceable(64) %0, ptr dereferenceable(64) %1, ptr dereferenceable(64) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <8 x double>, ptr %0 %4 = load <8 x double>, ptr %1 @@ -186,7 +186,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail11inplace_fmaIDv16_dEEvRT_S4_S4_(ptr dereferenceable(128) %0, ptr dereferenceable(128) %1, ptr dereferenceable(128) %2) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal11inplace_fmaIDv16_dEEvRT_S4_S4_(ptr dereferenceable(128) %0, ptr dereferenceable(128) %1, ptr dereferenceable(128) %2) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %3 = load <16 x double>, ptr %0 %4 = load <16 x double>, ptr %1 diff --git a/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.cpp index 94beade03..798fed834 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.cpp @@ -16,11 +16,12 @@ #include #include +#include #include namespace abacus { -namespace detail { +namespace internal { template void inplace_sqrt(T &t) { using ET = typename TypeTraits::ElementType; @@ -29,30 +30,30 @@ void inplace_sqrt(T &t) { *p = std::sqrt(*p); } } -} // namespace detail +} // namespace internal } // namespace abacus #ifdef __CA_BUILTINS_HALF_SUPPORT -template void abacus::detail::inplace_sqrt(abacus_half &); -template void abacus::detail::inplace_sqrt(abacus_half2 &); -template void abacus::detail::inplace_sqrt(abacus_half3 &); -template void abacus::detail::inplace_sqrt(abacus_half4 &); -template void abacus::detail::inplace_sqrt(abacus_half8 &); -template void abacus::detail::inplace_sqrt(abacus_half16 &); +template void abacus::internal::inplace_sqrt(abacus_half &); +template void abacus::internal::inplace_sqrt(abacus_half2 &); +template void abacus::internal::inplace_sqrt(abacus_half3 &); +template void abacus::internal::inplace_sqrt(abacus_half4 &); +template void abacus::internal::inplace_sqrt(abacus_half8 &); +template void abacus::internal::inplace_sqrt(abacus_half16 &); #endif // __CA_BUILTINS_HALF_SUPPORT -template void abacus::detail::inplace_sqrt(abacus_float &); -template void abacus::detail::inplace_sqrt(abacus_float2 &); -template void abacus::detail::inplace_sqrt(abacus_float3 &); -template void abacus::detail::inplace_sqrt(abacus_float4 &); -template void abacus::detail::inplace_sqrt(abacus_float8 &); -template void abacus::detail::inplace_sqrt(abacus_float16 &); +template void abacus::internal::inplace_sqrt(abacus_float &); +template void abacus::internal::inplace_sqrt(abacus_float2 &); +template void abacus::internal::inplace_sqrt(abacus_float3 &); +template void abacus::internal::inplace_sqrt(abacus_float4 &); +template void abacus::internal::inplace_sqrt(abacus_float8 &); +template void abacus::internal::inplace_sqrt(abacus_float16 &); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -template void abacus::detail::inplace_sqrt(abacus_double &); -template void abacus::detail::inplace_sqrt(abacus_double2 &); -template void abacus::detail::inplace_sqrt(abacus_double3 &); -template void abacus::detail::inplace_sqrt(abacus_double4 &); -template void abacus::detail::inplace_sqrt(abacus_double8 &); -template void abacus::detail::inplace_sqrt(abacus_double16 &); +template void abacus::internal::inplace_sqrt(abacus_double &); +template void abacus::internal::inplace_sqrt(abacus_double2 &); +template void abacus::internal::inplace_sqrt(abacus_double3 &); +template void abacus::internal::inplace_sqrt(abacus_double4 &); +template void abacus::internal::inplace_sqrt(abacus_double8 &); +template void abacus::internal::inplace_sqrt(abacus_double16 &); #endif // __CA_BUILTINS_DOUBLE_SUPPORT diff --git a/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.ll.in b/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.ll.in index caae121a3..5b2a3656e 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.ll.in +++ b/modules/compiler/builtins/abacus/source/abacus_math/inplace_sqrt.ll.in @@ -16,7 +16,7 @@ @target@ -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDF16_EEvRT_(ptr dereferenceable(2) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDF16_EEvRT_(ptr dereferenceable(2) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load half, ptr %0 %2 = call half @llvm.sqrt.f16(half %1) @@ -24,7 +24,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv2_DF16_EEvRT_(ptr dereferenceable(4) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv2_DF16_EEvRT_(ptr dereferenceable(4) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <2 x half>, ptr %0 %2 = call <2 x half> @llvm.sqrt.v2f16(<2 x half> %1) @@ -32,7 +32,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv3_DF16_EEvRT_(ptr dereferenceable(6) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv3_DF16_EEvRT_(ptr dereferenceable(6) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <3 x half>, ptr %0 %2 = call <3 x half> @llvm.sqrt.v3f16(<3 x half> %1) @@ -40,7 +40,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv4_DF16_EEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv4_DF16_EEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <4 x half>, ptr %0 %2 = call <4 x half> @llvm.sqrt.v4f16(<4 x half> %1) @@ -48,7 +48,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv8_DF16_EEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv8_DF16_EEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <8 x half>, ptr %0 %2 = call <8 x half> @llvm.sqrt.v8f16(<8 x half> %1) @@ -56,7 +56,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv16_DF16_EEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv16_DF16_EEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <16 x half>, ptr %0 %2 = call <16 x half> @llvm.sqrt.v16f16(<16 x half> %1) @@ -64,7 +64,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIfEEvRT_(ptr dereferenceable(4) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIfEEvRT_(ptr dereferenceable(4) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load float, ptr %0 %2 = call float @llvm.sqrt.f32(float %1) @@ -72,7 +72,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv2_fEEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv2_fEEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <2 x float>, ptr %0 %2 = call <2 x float> @llvm.sqrt.v2f32(<2 x float> %1) @@ -80,7 +80,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv3_fEEvRT_(ptr dereferenceable(12) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv3_fEEvRT_(ptr dereferenceable(12) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <3 x float>, ptr %0 %2 = call <3 x float> @llvm.sqrt.v3f32(<3 x float> %1) @@ -88,7 +88,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv4_fEEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv4_fEEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <4 x float>, ptr %0 %2 = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %1) @@ -96,7 +96,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv8_fEEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv8_fEEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <8 x float>, ptr %0 %2 = call <8 x float> @llvm.sqrt.v8f32(<8 x float> %1) @@ -104,7 +104,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv16_fEEvRT_(ptr dereferenceable(64) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv16_fEEvRT_(ptr dereferenceable(64) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <16 x float>, ptr %0 %2 = call <16 x float> @llvm.sqrt.v16f32(<16 x float> %1) @@ -112,7 +112,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIdEEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIdEEvRT_(ptr dereferenceable(8) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load double, ptr %0 %2 = call double @llvm.sqrt.f64(double %1) @@ -120,7 +120,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv2_dEEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv2_dEEvRT_(ptr dereferenceable(16) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <2 x double>, ptr %0 %2 = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %1) @@ -128,7 +128,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv3_dEEvRT_(ptr dereferenceable(24) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv3_dEEvRT_(ptr dereferenceable(24) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <3 x double>, ptr %0 %2 = call <3 x double> @llvm.sqrt.v3f64(<3 x double> %1) @@ -136,7 +136,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv4_dEEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv4_dEEvRT_(ptr dereferenceable(32) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <4 x double>, ptr %0 %2 = call <4 x double> @llvm.sqrt.v4f64(<4 x double> %1) @@ -144,7 +144,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv8_dEEvRT_(ptr dereferenceable(64) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv8_dEEvRT_(ptr dereferenceable(64) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <8 x double>, ptr %0 %2 = call <8 x double> @llvm.sqrt.v8f64(<8 x double> %1) @@ -152,7 +152,7 @@ entry: ret void } -define hidden spir_func void @_ZN6abacus6detail12inplace_sqrtIDv16_dEEvRT_(ptr dereferenceable(128) %0) local_unnamed_addr mustprogress nounwind alwaysinline { +define hidden spir_func void @_ZN6abacus8internal12inplace_sqrtIDv16_dEEvRT_(ptr dereferenceable(128) %0) local_unnamed_addr mustprogress nounwind alwaysinline { entry: %1 = load <16 x double>, ptr %0 %2 = call <16 x double> @llvm.sqrt.v16f64(<16 x double> %1) diff --git a/modules/compiler/builtins/abacus/source/abacus_math/log1p.cpp b/modules/compiler/builtins/abacus/source/abacus_math/log1p.cpp index 96341338f..fd7982c1c 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/log1p.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/log1p.cpp @@ -262,7 +262,7 @@ struct helper { } const abacus_float poly_approx = abacus::internal::horner_polynomial( - significand, __codeplay_log1p_coeff + polynomial_select * (size_t)10, + significand, __codeplay_log1p_coeff + (polynomial_select * (size_t)10), 10); if (polynomial_select != 0) { @@ -270,7 +270,7 @@ struct helper { } const abacus_float result = - significand + significand * significand * poly_approx; + significand + (significand * significand * poly_approx); const abacus_float fexponent = (abacus_float)(exponent); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/mad.cpp b/modules/compiler/builtins/abacus/source/abacus_math/mad.cpp index 2d4542a08..1c7f97b75 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/mad.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/mad.cpp @@ -20,7 +20,7 @@ namespace { template inline T mad_helper(T x, T y, T z) { - return x * y + z; + return (x * y) + z; } } // namespace diff --git a/modules/compiler/builtins/abacus/source/abacus_math/nan.cpp b/modules/compiler/builtins/abacus/source/abacus_math/nan.cpp index e634e173c..c19851a99 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/nan.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/nan.cpp @@ -16,6 +16,7 @@ #include #include +#include #include namespace { diff --git a/modules/compiler/builtins/abacus/source/abacus_math/native_exp.cpp b/modules/compiler/builtins/abacus/source/abacus_math/native_exp.cpp index 8de87678a..d731cbb00 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/native_exp.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/native_exp.cpp @@ -36,7 +36,7 @@ T native_exp(const T x) { // r = e^(k * ln(2)) * e^f // r = 2^k * e^f const SignedType k = abacus::internal::floor_unsafe(x * ln2recip); - const T f = x - abacus::detail::cast::convert(k) * ln2; + const T f = x - (abacus::detail::cast::convert(k) * ln2); const abacus_float polynomial[3] = {1.00172475857779f, .948768609890313f, .701815635555134f}; diff --git a/modules/compiler/builtins/abacus/source/abacus_math/native_exp10.cpp b/modules/compiler/builtins/abacus/source/abacus_math/native_exp10.cpp index 9f944177a..2b70fe57d 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/native_exp10.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/native_exp10.cpp @@ -35,7 +35,7 @@ T native_exp10(const T x) { // r = 10^(k * log10(2)) * 10^f // r = 2^k * 10^f const SignedType k = abacus::internal::floor_unsafe(x * log102recip); - const T f = x - abacus::detail::cast::convert(k) * log102; + const T f = x - (abacus::detail::cast::convert(k) * log102); const abacus_float polynomial[3] = {1.00172475857780f, 2.18462045783410f, 3.72095499205386f}; diff --git a/modules/compiler/builtins/abacus/source/abacus_math/native_log.cpp b/modules/compiler/builtins/abacus/source/abacus_math/native_log.cpp index 1eae56f2a..12ba571bd 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/native_log.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/native_log.cpp @@ -40,7 +40,7 @@ T native_log(const T x) { const T logf = abacus::internal::horner_polynomial(f - 1, polynomial); const T oneOverlog2e = 0.693147180559945309417232121458; - return f * logf + abacus::detail::cast::convert(n) * oneOverlog2e; + return (f * logf) + (abacus::detail::cast::convert(n) * oneOverlog2e); } } // namespace diff --git a/modules/compiler/builtins/abacus/source/abacus_math/native_log10.cpp b/modules/compiler/builtins/abacus/source/abacus_math/native_log10.cpp index 303128517..06ba2d4af 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/native_log10.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/native_log10.cpp @@ -40,7 +40,7 @@ T native_log10(const T x) { const T log10f = abacus::internal::horner_polynomial(f - 1, polynomial); const abacus_float oneOverlog210 = 0.301029995663981195213738894725f; - return f * log10f + abacus::detail::cast::convert(n) * oneOverlog210; + return (f * log10f) + (abacus::detail::cast::convert(n) * oneOverlog210); } } // namespace diff --git a/modules/compiler/builtins/abacus/source/abacus_math/pown.cpp b/modules/compiler/builtins/abacus/source/abacus_math/pown.cpp index 000585ab0..627f18cce 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/pown.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/pown.cpp @@ -347,9 +347,9 @@ struct helper { exponent_mantissa -= abacus::detail::cast::convert(trunced_exponent_mantissa); - T result = (T)1.0 + exponent_mantissa * abacus::internal::horner_polynomial( - exponent_mantissa, - __codeplay_pow_unsafe_coeffD); + T result = (T)1.0 + (exponent_mantissa * + abacus::internal::horner_polynomial( + exponent_mantissa, __codeplay_pow_unsafe_coeffD)); result = __abacus_ldexp( result, abacus::detail::cast::convert(exponent_floor)); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/remquo.cpp b/modules/compiler/builtins/abacus/source/abacus_math/remquo.cpp index 5b85c28ab..a2ae9c66d 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/remquo.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/remquo.cpp @@ -68,7 +68,7 @@ T upscaleDenormal(const T x) { const UnsignedType xUint = abacus::detail::cast::as(x); const UnsignedType scale = xUint | lowExpBit; - const T result = abacus::detail::cast::as(scale) * scaleFactor::up - + const T result = (abacus::detail::cast::as(scale) * scaleFactor::up) - scaleFactor::adjust; return result; } @@ -160,8 +160,7 @@ abacus_double remquo_helper_scalar(const abacus_double x, const abacus_double m, result -= mAbs; } - *out_quo = - quotient * __abacus_select(1, -1, (abacus_int)__abacus_signbit(x * m)); + *out_quo = quotient * __abacus_select(1, -1, __abacus_signbit(x * m)); return __abacus_select(result, -result, (abacus_long)(x < 0.0)); } diff --git a/modules/compiler/builtins/abacus/source/abacus_math/rsqrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/rsqrt.cpp index e9dbd82b5..24aa21a5a 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/rsqrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/rsqrt.cpp @@ -97,7 +97,7 @@ struct helper { // (x * 2^24) T processedX = __abacus_select( x, - abacus::detail::cast::as(xUint | hiddenBit) * 16777216.0f - + (abacus::detail::cast::as(xUint | hiddenBit) * 16777216.0f) - __abacus_as_float(0x0C800000), xSmall); diff --git a/modules/compiler/builtins/abacus/source/abacus_math/sinh.cpp b/modules/compiler/builtins/abacus/source/abacus_math/sinh.cpp index a4f793683..f560fee3e 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/sinh.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/sinh.cpp @@ -107,7 +107,7 @@ struct helper { const T ex = __abacus_expm1(xNew); - const T ex_rcp = (T)1.0f / (ex + 1.0f) - 1.0f; + const T ex_rcp = ((T)1.0f / (ex + 1.0f)) - 1.0f; const T ans = (scale * ex_rcp + 1.0f) * ex; @@ -132,7 +132,7 @@ struct helper { const T ex = __abacus_expm1(xNew); - const T ex_rcp = (T)1.0 / (ex + 1.0) - 1.0; + const T ex_rcp = ((T)1.0 / (ex + 1.0)) - 1.0; const T ans = (scale * ex_rcp + 1.0) * ex; diff --git a/modules/compiler/builtins/abacus/source/abacus_math/sqrt.cpp b/modules/compiler/builtins/abacus/source/abacus_math/sqrt.cpp index 4ebc95747..f51490d69 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/sqrt.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/sqrt.cpp @@ -15,17 +15,14 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include +#include namespace abacus { -namespace detail { -template -void inplace_sqrt(T &); -} // namespace detail - namespace internal { template T sqrt(T x) { - abacus::detail::inplace_sqrt(x); + inplace_sqrt(x); return x; } } // namespace internal diff --git a/modules/compiler/builtins/abacus/source/abacus_math/tan.cpp b/modules/compiler/builtins/abacus/source/abacus_math/tan.cpp index f0cf4d2f7..4c533ec62 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/tan.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/tan.cpp @@ -29,11 +29,11 @@ struct helper; template struct helper { static T numerator(const T x) { - return x * 0.999999986f - x * x * x * 0.0958010197f; + return (x * 0.999999986f) - (x * x * x * 0.0958010197f); } static T denominator(const T x) { - return (T)1.f - x * x * 0.429135022f + x * x * x * x * 0.00971659383f; + return (T)1.f - (x * x * 0.429135022f) + (x * x * x * x * 0.00971659383f); } }; @@ -51,8 +51,8 @@ struct helper { -5.9926098258796618469322956805282730e-12}; const T y = abacus::internal::horner_polynomial(xSq, polynomial); - return x * .78539816339744830961566084582040377 + - x * xSq * .85737772729049709971879473936502462 * y; + return (x * .78539816339744830961566084582040377) + + (x * xSq * .85737772729049709971879473936502462 * y); } static T denominator(const T x) { @@ -66,7 +66,7 @@ struct helper { -5.0244514118826496404940417101797213e-10}; const T y = abacus::internal::horner_polynomial(xSq, polynomial); - return xSq * y * .85737772729049709971879473936502462 + 1.0; + return (xSq * y * .85737772729049709971879473936502462) + 1.0; } }; #endif // __CA_BUILTINS_DOUBLE_SUPPORT diff --git a/modules/compiler/builtins/abacus/source/abacus_math/tanpi.cpp b/modules/compiler/builtins/abacus/source/abacus_math/tanpi.cpp index 04f259bc3..baa936386 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/tanpi.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/tanpi.cpp @@ -77,11 +77,12 @@ struct helper { template struct helper { static T numerator(const T x) { - return x * 3.14159260961f - x * x * x * 2.97043292307f; + return (x * 3.14159260961f) - (x * x * x * 2.97043292307f); } static T denominator(const T x) { - return (T)1.f - x * x * 4.23539290179f + x * x * x * x * 0.946484572927f; + return (T)1.f - (x * x * 4.23539290179f) + + (x * x * x * x * 0.946484572927f); } static T handle_edge_cases(const T, const T ans) { return ans; } diff --git a/modules/compiler/builtins/abacus/source/abacus_math/tgamma.cpp b/modules/compiler/builtins/abacus/source/abacus_math/tgamma.cpp index cd504a693..65e9b5360 100644 --- a/modules/compiler/builtins/abacus/source/abacus_math/tgamma.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_math/tgamma.cpp @@ -471,8 +471,8 @@ abacus_float ABACUS_API __abacus_tgamma(abacus_float x) { // Polynomial approximation of gamma(x) / (exp(-x) * x^((0.5 * x) - 0.25)) const abacus_float polynomial_extension = - (1.0f + - (-139.0f + (180.0f + 4320.0f * xx) * xx) / ((51840.f * xx) * (xx * xx))); + (1.0f + ((-139.0f + (180.0f + 4320.0f * xx) * xx) / + ((51840.f * xx) * (xx * xx)))); result = result * polynomial_extension; diff --git a/modules/compiler/builtins/abacus/source/abacus_misc/shuffle.cpp b/modules/compiler/builtins/abacus/source/abacus_misc/shuffle.cpp index 84b943b7c..abd40d6c3 100644 --- a/modules/compiler/builtins/abacus/source/abacus_misc/shuffle.cpp +++ b/modules/compiler/builtins/abacus/source/abacus_misc/shuffle.cpp @@ -28,7 +28,7 @@ template const unsigned SizeLaundry::num_elements = TypeTraits::num_elements; template -R shuffle(const T x, const M m) { +static R shuffle(const T x, const M m) { typedef typename TypeTraits::ElementType MElementType; const M maskedM = m % abacus::detail::cast::convert( SizeLaundry::num_elements); diff --git a/modules/compiler/builtins/include/builtins/builtins.h b/modules/compiler/builtins/include/builtins/builtins.h index 42ca42e88..573043450 100644 --- a/modules/compiler/builtins/include/builtins/builtins.h +++ b/modules/compiler/builtins/include/builtins/builtins.h @@ -257,12 +257,12 @@ char2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char2(ushort arg); #ifdef __CA_BUILTINS_HALF_SUPPORT char2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char2(half arg); #endif // __CA_BUILTINS_HALF_SUPPORT -uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar2(char2 arg); -uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar2(short arg); -uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar2(ushort arg); +uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar2( + char2 arg); +uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar2( + short arg); +uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar2( + ushort arg); #ifdef __CA_BUILTINS_HALF_SUPPORT uchar2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar2(half arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -272,12 +272,12 @@ short __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short(ushort arg); #ifdef __CA_BUILTINS_HALF_SUPPORT short __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short(half arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort(char2 arg); -ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort(uchar2 arg); -ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort(short arg); +ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort( + char2 arg); +ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort( + uchar2 arg); +ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort( + short arg); #ifdef __CA_BUILTINS_HALF_SUPPORT ushort __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort(half arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -289,64 +289,64 @@ half __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half(ushort arg); #endif // __CA_BUILTINS_HALF_SUPPORT char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(uchar4 arg); char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(short2 arg); -char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char4(ushort2 arg); +char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4( + ushort2 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(half2 arg); #endif // __CA_BUILTINS_HALF_SUPPORT char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(int arg); char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(uint arg); char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(float arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(char4 arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(short2 arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(ushort2 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + char4 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + short2 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + ushort2 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(half2 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + half2 arg); #endif // __CA_BUILTINS_HALF_SUPPORT uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4(int arg); uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4(uint arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(float arg); -short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short2(char4 arg); -short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short2(uchar4 arg); -short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short2(ushort2 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + float arg); +short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2( + char4 arg); +short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2( + uchar4 arg); +short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2( + ushort2 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short2(half2 arg); +short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2( + half2 arg); #endif // __CA_BUILTINS_HALF_SUPPORT short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2(int arg); short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2(uint arg); -short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short2(float arg); -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(char4 arg); -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(uchar4 arg); -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(short2 arg); +short2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short2( + float arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + char4 arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + uchar4 arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + short2 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(half2 arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + half2 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(int arg); -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(uint arg); -ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort2(float arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + int arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + uint arg); +ushort2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort2( + float arg); #ifdef __CA_BUILTINS_HALF_SUPPORT half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(char4 arg); half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(uchar4 arg); half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(short2 arg); -half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half2(ushort2 arg); +half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2( + ushort2 arg); half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(int arg); half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(uint arg); half2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half2(float arg); @@ -372,8 +372,8 @@ uint __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint(float arg); float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(char4 arg); float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(uchar4 arg); float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(short2 arg); -float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float(ushort2 arg); +float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float( + ushort2 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(half2 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -381,8 +381,8 @@ float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(int arg); float __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float(uint arg); char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8(uchar8 arg); char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8(short4 arg); -char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char8(ushort4 arg); +char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8(half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -394,80 +394,80 @@ char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8(ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT char8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char8(double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(char8 arg); -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(short4 arg); -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(ushort4 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + char8 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + short4 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(half4 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8(int2 arg); -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(uint2 arg); -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(float2 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + uint2 arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + float2 arg); uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8(long arg); -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(ulong arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar8(double arg); +uchar8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar8( + double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(char8 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(uchar8 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(ushort4 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + char8 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + uchar8 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(half4 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4(int2 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(uint2 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(float2 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + uint2 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + float2 arg); short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4(long arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(ulong arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(double arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(char8 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(uchar8 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(short4 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + char8 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + uchar8 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + short4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(half4 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(int2 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(uint2 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(float2 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(long arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(ulong arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + int2 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + uint2 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + float2 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + long arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(double arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(char8 arg); half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(uchar8 arg); half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(short4 arg); -half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half4(ushort4 arg); +half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4( + ushort4 arg); half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(int2 arg); half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(uint2 arg); half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(float2 arg); @@ -494,8 +494,8 @@ int2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int2(double arg); uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(char8 arg); uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(uchar8 arg); uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(short4 arg); -uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint2(ushort4 arg); +uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -506,27 +506,27 @@ uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT uint2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint2(double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(char8 arg); -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(uchar8 arg); -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(short4 arg); -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(ushort4 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + char8 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + uchar8 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + short4 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(half4 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2(int2 arg); -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(uint2 arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + uint2 arg); float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2(long arg); -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(ulong arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + ulong arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float2(double arg); +float2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float2( + double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT long __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long(char8 arg); long __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long(uchar8 arg); @@ -545,8 +545,8 @@ long __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long(double arg); ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(char8 arg); ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(uchar8 arg); ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(short4 arg); -ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong(ushort4 arg); +ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -558,136 +558,136 @@ ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(long arg); ulong __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong(double arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(char8 arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(uchar8 arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(short4 arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(ushort4 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + char8 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + uchar8 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + short4 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + ushort4 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(half4 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double(int2 arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(uint2 arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(float2 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + uint2 arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + float2 arg); double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double(long arg); -double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double(ulong arg); +double __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double( + ulong arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(uchar16 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(short8 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(ushort8 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + uchar16 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + short8 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(half8 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16(int4 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(uint4 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(float4 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(long2 arg); -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(ulong2 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + uint4 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + float4 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + long2 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_char16(double2 arg); +char16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char16( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(char16 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(short8 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(ushort8 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + char16 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + short8 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(half8 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(int4 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(uint4 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(float4 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(long2 arg); -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(ulong2 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + int4 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + uint4 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + float4 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + long2 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar16(double2 arg); +uchar16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar16( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(char16 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(uchar16 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(ushort8 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + char16 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + uchar16 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(half8 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8(int4 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(uint4 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(float4 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(long2 arg); -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(ulong2 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + uint4 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + float4 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + long2 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short8(double2 arg); +short8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short8( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(char16 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(uchar16 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(short8 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + char16 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + uchar16 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + short8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(half8 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(int4 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(uint4 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(float4 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(long2 arg); -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(ulong2 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + int4 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + uint4 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + float4 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + long2 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort8(double2 arg); +ushort8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort8( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(char16 arg); -half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half8(uchar16 arg); +half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8( + uchar16 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(short8 arg); -half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half8(ushort8 arg); +half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8( + ushort8 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(int4 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(uint4 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(float4 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(long2 arg); half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8(ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half8(double2 arg); +half8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half8( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #endif // __CA_BUILTINS_HALF_SUPPORT int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(char16 arg); @@ -705,11 +705,11 @@ int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(ulong2 arg); int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(char16 arg); -uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint4(uchar16 arg); +uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4( + uchar16 arg); uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(short8 arg); -uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint4(ushort8 arg); +uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -718,38 +718,38 @@ uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(float4 arg); uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(long2 arg); uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint4(double2 arg); +uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(char16 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(uchar16 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(short8 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(ushort8 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + char16 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + uchar16 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + short8 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(half8 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4(int4 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(uint4 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(long2 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(ulong2 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + uint4 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + long2 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(double2 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(char16 arg); -long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long2(uchar16 arg); +long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2( + uchar16 arg); long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(short8 arg); -long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long2(ushort8 arg); +long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -758,113 +758,113 @@ long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(uint4 arg); long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(float4 arg); long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2(ulong2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long2(double2 arg); +long2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long2( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(char16 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(uchar16 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(short8 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(ushort8 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + char16 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + uchar16 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + short8 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(half8 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2(int4 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(uint4 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(float4 arg); -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(long2 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + uint4 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + float4 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + long2 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong2(double2 arg); +ulong2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong2( + double2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(char16 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(uchar16 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(short8 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(ushort8 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + char16 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + uchar16 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + short8 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + ushort8 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(half8 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + half8 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(int4 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(uint4 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(float4 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(long2 arg); -double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double2(ulong2 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + int4 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + uint4 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + float4 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + long2 arg); +double2 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double2( + ulong2 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(ushort16 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(half16 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(int8 arg); -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(uint8 arg); -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(float8 arg); -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(long4 arg); -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(ulong4 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + int8 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + uint8 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + float8 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + long4 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short16(double4 arg); +short16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short16( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(short16 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + short16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(half16 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(int8 arg); -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(uint8 arg); -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(float8 arg); -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(long4 arg); -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(ulong4 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + int8 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + uint8 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + float8 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + long4 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort16(double4 arg); +ushort16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort16( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(short16 arg); -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(ushort16 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + short16 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + ushort16 arg); half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16(int8 arg); -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(uint8 arg); -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(float8 arg); -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(long4 arg); -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(ulong4 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + uint8 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + float8 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + long4 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half16(double4 arg); +half16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half16( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #endif // __CA_BUILTINS_HALF_SUPPORT int8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int8(short16 arg); @@ -879,10 +879,10 @@ int8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int8(ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT int8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int8(double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint8(short16 arg); -uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint8(ushort16 arg); +uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8( + short16 arg); +uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8(half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -891,32 +891,32 @@ uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8(float8 arg); uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8(long4 arg); uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8(ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint8(double4 arg); +uint8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint8( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(short16 arg); -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(ushort16 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + short16 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(half16 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8(int8 arg); -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(uint8 arg); -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(long4 arg); -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(ulong4 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + uint8 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + long4 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float8(double4 arg); +float8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float8( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long4(short16 arg); -long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long4(ushort16 arg); +long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4( + short16 arg); +long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT @@ -925,209 +925,209 @@ long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(uint8 arg); long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(float8 arg); long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(ulong4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long4(double4 arg); +long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(short16 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(ushort16 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + short16 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(half16 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4(int8 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(uint8 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(float8 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(long4 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + uint8 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + float8 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + long4 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(double4 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(short16 arg); -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(ushort16 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + short16 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + ushort16 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(half16 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + half16 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(int8 arg); -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(uint8 arg); -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(float8 arg); -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(long4 arg); -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(ulong4 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + int8 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + uint8 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + float8 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + long4 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + ulong4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int16(uint16 arg); -int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_int16(float16 arg); +int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int16( + float16 arg); int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int16(long8 arg); int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int16(ulong8 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_int16(double8 arg); +int16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int16( + double8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint16(int16 arg); -uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint16(float16 arg); -uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint16(long8 arg); -uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint16(ulong8 arg); +uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint16( + int16 arg); +uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint16( + float16 arg); +uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint16( + long8 arg); +uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint16( + ulong8 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uint16(double8 arg); +uint16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint16( + double8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float16(int16 arg); -float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float16(uint16 arg); -float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float16(long8 arg); -float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float16(ulong8 arg); +float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float16( + int16 arg); +float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float16( + uint16 arg); +float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float16( + long8 arg); +float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float16( + ulong8 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float16(double8 arg); +float16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float16( + double8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long8(int16 arg); long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long8(uint16 arg); -long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long8(float16 arg); +long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long8( + float16 arg); long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long8(ulong8 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long8(double8 arg); +long8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long8( + double8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong8(int16 arg); -ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong8(uint16 arg); -ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong8(float16 arg); -ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong8(long8 arg); +ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong8( + int16 arg); +ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong8( + uint16 arg); +ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong8( + float16 arg); +ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong8( + long8 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong8(double8 arg); +ulong8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong8( + double8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double8(int16 arg); -double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double8(uint16 arg); -double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double8(float16 arg); -double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double8(long8 arg); -double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double8(ulong8 arg); +double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double8( + int16 arg); +double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double8( + uint16 arg); +double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double8( + float16 arg); +double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double8( + long8 arg); +double8 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double8( + ulong8 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -long16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long16(ulong16 arg); +long16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long16( + ulong16 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long16(double16 arg); +long16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long16( + double16 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong16(long16 arg); +ulong16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong16( + long16 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong16(double16 arg); +ulong16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong16( + double16 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double16(long16 arg); -double16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double16(ulong16 arg); +double16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double16( + long16 arg); +double16 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double16( + ulong16 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT char3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char3(uchar3 arg); -uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar3(char3 arg); +uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar3( + char3 arg); char3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char3(char4 arg); char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(char3 arg); char3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char3(uchar4 arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(char3 arg); -uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar3(char4 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + char3 arg); +uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar3( + char4 arg); char4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_char4(uchar3 arg); -uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar3(uchar4 arg); -uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_uchar4(uchar3 arg); -short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short3(ushort3 arg); +uchar3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar3( + uchar4 arg); +uchar4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uchar4( + uchar3 arg); +short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short3( + ushort3 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short3(half3 arg); +short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short3( + half3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort3(short3 arg); +ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort3( + short3 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort3(half3 arg); +ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort3( + half3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half3(short3 arg); -half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half3(ushort3 arg); +half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half3( + ushort3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short3(short4 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(short3 arg); -short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short3(ushort4 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(short3 arg); +short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short3( + short4 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + short3 arg); +short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short3( + ushort4 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + short3 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short3(half4 arg); +short3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short3( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4(short3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT -ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort3(short4 arg); -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(ushort3 arg); -ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort3(ushort4 arg); -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(ushort3 arg); +ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort3( + short4 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + ushort3 arg); +ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort3( + ushort4 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + ushort3 arg); #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort3(half4 arg); +ushort3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort3( + half4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT -half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half4(ushort3 arg); +half4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half4( + ushort3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half3(short4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT -short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_short4(half3 arg); +short4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_short4( + half3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT -half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_half3(ushort4 arg); +half3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_half3( + ushort4 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT -ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ushort4(half3 arg); +ushort4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ushort4( + half3 arg); #endif // __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT #ifdef __CA_BUILTINS_HALF_SUPPORT @@ -1144,8 +1144,8 @@ int3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int3(float3 arg); uint3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint3(int3 arg); uint3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint3(float3 arg); float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float3(int3 arg); -float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float3(uint3 arg); +float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float3( + uint3 arg); int3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int3(int4 arg); int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(int3 arg); int3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int3(uint4 arg); @@ -1157,88 +1157,88 @@ int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(uint3 arg); uint3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint3(uint4 arg); uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(uint3 arg); uint3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint3(float4 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(uint3 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + uint3 arg); float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float3(int4 arg); int4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_int4(float3 arg); -float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float3(uint4 arg); +float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float3( + uint4 arg); uint4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_uint4(float3 arg); -float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float3(float4 arg); -float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_float4(float3 arg); +float3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float3( + float4 arg); +float4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_float4( + float3 arg); long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long3(ulong3 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long3(double3 arg); +long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long3( + double3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong3(long3 arg); +ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong3( + long3 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong3(double3 arg); +ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong3( + double3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double3(long3 arg); -double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double3(ulong3 arg); +double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double3( + long3 arg); +double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double3( + ulong3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long3(long4 arg); long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(long3 arg); long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long3(ulong4 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(long3 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + long3 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long3(double4 arg); +long3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long3( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(long3 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + long3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT -ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong3(long4 arg); +ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong3( + long4 arg); long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4(ulong3 arg); -ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong3(ulong4 arg); -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(ulong3 arg); +ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong3( + ulong4 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + ulong3 arg); #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong3(double4 arg); +ulong3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong3( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(ulong3 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + ulong3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double3(long4 arg); +double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double3( + long4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_long4(double3 arg); +long4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_long4( + double3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double3(ulong4 arg); +double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double3( + ulong4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_ulong4(double3 arg); +ulong4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_ulong4( + double3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double3(double4 arg); +double3 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double3( + double4 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #endif // __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT #ifdef __CA_BUILTINS_DOUBLE_SUPPORT -double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) -as_double4(double3 arg); +double4 __CL_CONST_ATTRIBUTES __attribute__((always_inline)) as_double4( + double3 arg); #endif // __CA_BUILTINS_DOUBLE_SUPPORT #endif // __CA_BUILTINS_DOUBLE_SUPPORT diff --git a/modules/compiler/builtins/include/builtins/cxxbuiltins.h b/modules/compiler/builtins/include/builtins/cxxbuiltins.h index 5682efca1..20b328d6a 100644 --- a/modules/compiler/builtins/include/builtins/cxxbuiltins.h +++ b/modules/compiler/builtins/include/builtins/cxxbuiltins.h @@ -821,26 +821,26 @@ struct FPBits; // The number of bits in each component of an IEEE754 16-bit float. template <> struct FPBits { - const static uint Mantissa = 10; - const static uint Exponent = 5; - const static uint Sign = 1; + static const uint Mantissa = 10; + static const uint Exponent = 5; + static const uint Sign = 1; }; // The number of bits in each component of an IEEE754 32-bit float. template <> struct FPBits { - const static uint Mantissa = 23; - const static uint Exponent = 8; - const static uint Sign = 1; + static const uint Mantissa = 23; + static const uint Exponent = 8; + static const uint Sign = 1; }; #ifdef __CA_BUILTINS_DOUBLE_SUPPORT // The number of bits in each component of an IEEE754 64-bit float. template <> struct FPBits { - const static uint Mantissa = 52; - const static uint Exponent = 11; - const static uint Sign = 1; + static const uint Mantissa = 52; + static const uint Exponent = 11; + static const uint Sign = 1; }; #endif // __CA_BUILTINS_DOUBLE_SUPPORT @@ -871,7 +871,7 @@ struct Shape { }; // The size of this type. - const static uint NumBits = Bits::Mantissa + Bits::Exponent + Bits::Sign; + static const uint NumBits = Bits::Mantissa + Bits::Exponent + Bits::Sign; static_assert(NumBits == (sizeof(T) * CHAR_BIT), "Unknown floating point bitwidth used"); @@ -880,12 +880,12 @@ struct Shape { // defined by the IEEE754 specification, but are 2^(BitsInExponent-1) - 1, // i.e. pre-bias 0 is in the middle of the range. // Spec values are half: 15, float: 127, double: 1023. - const static uint Bias = (1u << (Bits::Exponent - 1u)) - 1u; + static const uint Bias = (1u << (Bits::Exponent - 1u)) - 1u; // Setting a single bit, or all the exponent or mantissa bits to all 1's. - const static UnsignedType ONE = 1u; - const static UnsignedType ExponentOnes = (ONE << Bits::Exponent) - ONE; - const static UnsignedType MantissaOnes = (ONE << Bits::Mantissa) - ONE; + static const UnsignedType ONE = 1u; + static const UnsignedType ExponentOnes = (ONE << Bits::Exponent) - ONE; + static const UnsignedType MantissaOnes = (ONE << Bits::Mantissa) - ONE; // If both exponent and mantissa is zero then this number is a zero. static inline bool Zero(Float x) { diff --git a/modules/compiler/builtins/include/builtins/image_library_integration.h b/modules/compiler/builtins/include/builtins/image_library_integration.h index 690860713..e67618557 100644 --- a/modules/compiler/builtins/include/builtins/image_library_integration.h +++ b/modules/compiler/builtins/include/builtins/image_library_integration.h @@ -336,30 +336,30 @@ struct Shape { UInt Sign : 1; } r; }; - const static UInt Float16Bias = 15; - const static UInt Float32Bias = 127; - static inline bool Zero(Float16 x) { + static const UInt Float16Bias = 15; + static const UInt Float32Bias = 127; + static bool Zero(Float16 x) { return ((x.r.Exponent == 0) && (x.r.Mantissa == 0)); } - static inline bool Zero(Float32 x) { + static bool Zero(Float32 x) { return ((x.r.Exponent == 0) && (x.r.Mantissa == 0)); } - static inline bool Denormal(Float16 x) { + static bool Denormal(Float16 x) { return ((x.r.Exponent == 0) && (x.r.Mantissa != 0)); } - static inline bool Denormal(Float32 x) { + static bool Denormal(Float32 x) { return ((x.r.Exponent == 0) && (x.r.Mantissa != 0)); } - static inline bool Inf(Float16 x) { + static bool Inf(Float16 x) { return ((x.r.Exponent == 0x1f) && (x.r.Mantissa == 0)); } - static inline bool Inf(Float32 x) { + static bool Inf(Float32 x) { return ((x.r.Exponent == 0xff) && (x.r.Mantissa == 0)); } - static inline bool NaN(Float16 x) { + static bool NaN(Float16 x) { return ((x.r.Exponent == 0x1f) && (x.r.Mantissa != 0)); } - static inline bool NaN(Float32 x) { + static bool NaN(Float32 x) { return ((x.r.Exponent == 0xff) && (x.r.Mantissa != 0)); } }; @@ -368,7 +368,7 @@ static inline UShort HalfDownConvertHelper_rte(const Float payload); template <> struct HalfConvertHelper_rte { - static inline UShort RoundNearInfinity(bool sign) { + static UShort RoundNearInfinity(bool sign) { Shape::Float16 out; out.r.Mantissa = 0; @@ -377,7 +377,7 @@ struct HalfConvertHelper_rte { return out.f; } - static inline UInt ShiftRightLogical(UInt x, UInt shift, bool sign) { + static UInt ShiftRightLogical(UInt x, UInt shift, bool sign) { (void)sign; if (shift > 32u) { return 0u; diff --git a/modules/compiler/builtins/libimg/source/host.cpp b/modules/compiler/builtins/libimg/source/host.cpp index 2be44b8ec..f97b9d344 100644 --- a/modules/compiler/builtins/libimg/source/host.cpp +++ b/modules/compiler/builtins/libimg/source/host.cpp @@ -122,11 +122,11 @@ size_t libimg::HostGetImageOriginOffset(const cl_image_format &format, return row_position; case CL_MEM_OBJECT_IMAGE1D_ARRAY: case CL_MEM_OBJECT_IMAGE2D: - return row_position + desc.image_row_pitch * origin[1]; + return row_position + (desc.image_row_pitch * origin[1]); case CL_MEM_OBJECT_IMAGE2D_ARRAY: case CL_MEM_OBJECT_IMAGE3D: - return row_position + desc.image_row_pitch * origin[1] + - desc.image_slice_pitch * origin[2]; + return row_position + (desc.image_row_pitch * origin[1]) + + (desc.image_slice_pitch * origin[2]); default: IMG_UNREACHABLE("Not an image mem object type!"); return 0; @@ -563,16 +563,16 @@ void libimg::HostReadImage(const HostImage *image, const size_t origin[3], const size_t dst_slice_pitch, uint8_t *dst) { const ImageMetaData &desc = image->image.meta_data; - const uint8_t *src = image->image.raw_data + origin[0] * desc.pixel_size; + const uint8_t *src = image->image.raw_data + (origin[0] * desc.pixel_size); const size_t row_size = region[0] * desc.pixel_size; for (size_t z = 0; z < region[2]; ++z) { - const uint8_t *src_slice = src + (z + origin[2]) * desc.slice_pitch; - uint8_t *dst_slice = dst + z * dst_slice_pitch; + const uint8_t *src_slice = src + ((z + origin[2]) * desc.slice_pitch); + uint8_t *dst_slice = dst + (z * dst_slice_pitch); for (size_t y = 0; y < region[1]; ++y) { - const uint8_t *src_row = src_slice + (y + origin[1]) * desc.row_pitch; - uint8_t *dst_row = dst_slice + y * dst_row_pitch; + const uint8_t *src_row = src_slice + ((y + origin[1]) * desc.row_pitch); + uint8_t *dst_row = dst_slice + (y * dst_row_pitch); std::memmove(dst_row, src_row, row_size); } } @@ -583,22 +583,23 @@ void libimg::HostWriteImage(HostImage *image, const size_t origin[3], const size_t src_slice_pitch, const uint8_t *src) { const ImageMetaData &desc = image->image.meta_data; - uint8_t *dst = image->image.raw_data + origin[0] * desc.pixel_size; + uint8_t *dst = image->image.raw_data + (origin[0] * desc.pixel_size); const size_t row_size = region[0] * desc.pixel_size; for (size_t z = 0; z < region[2]; ++z) { - const uint8_t *src_slice = src + z * src_slice_pitch; - uint8_t *dst_slice = dst + (z + origin[2]) * desc.slice_pitch; + const uint8_t *src_slice = src + (z * src_slice_pitch); + uint8_t *dst_slice = dst + ((z + origin[2]) * desc.slice_pitch); for (size_t y = 0; y < region[1]; ++y) { - const uint8_t *src_row = src_slice + y * src_row_pitch; - uint8_t *dst_row = dst_slice + (y + origin[1]) * desc.row_pitch; + const uint8_t *src_row = src_slice + (y * src_row_pitch); + uint8_t *dst_row = dst_slice + ((y + origin[1]) * desc.row_pitch); std::memmove(dst_row, src_row, row_size); } } } -libimg::UInt4 ShuffleOrder(const libimg::UInt order, const libimg::UInt4 &in) { +static libimg::UInt4 ShuffleOrder(const libimg::UInt order, + const libimg::UInt4 &in) { switch (order) case CL_A: { return libimg::make(in[3], 0u, 0u, 0u); @@ -707,15 +708,15 @@ void libimg::HostFillImage(HostImage *image, const void *fill_color, } } - uint8_t *dst = image->image.raw_data + origin[0] * desc.pixel_size + - origin[1] * desc.row_pitch + origin[2] * desc.slice_pitch; + uint8_t *dst = image->image.raw_data + (origin[0] * desc.pixel_size) + + (origin[1] * desc.row_pitch) + (origin[2] * desc.slice_pitch); for (size_t z = 0; z < region[2]; ++z) { - uint8_t *dst_slice = dst + z * desc.slice_pitch; + uint8_t *dst_slice = dst + (z * desc.slice_pitch); for (size_t y = 0; y < region[1]; ++y) { - uint8_t *dst_row = dst_slice + y * desc.row_pitch; + uint8_t *dst_row = dst_slice + (y * desc.row_pitch); for (size_t x = 0; x < region[0]; ++x) { - uint8_t *dst_pixel = dst_row + x * desc.pixel_size; + uint8_t *dst_pixel = dst_row + (x * desc.pixel_size); std::memcpy(dst_pixel, final_color, desc.pixel_size); } } @@ -729,9 +730,9 @@ void libimg::HostCopyImage(const HostImage *src_image, HostImage *dst_image, const ImageMetaData &dst_desc = dst_image->image.meta_data; const uint8_t *const src = - src_image->image.raw_data + src_origin[0] * src_desc.pixel_size; + src_image->image.raw_data + (src_origin[0] * src_desc.pixel_size); uint8_t *const dst = - dst_image->image.raw_data + dst_origin[0] * dst_desc.pixel_size; + dst_image->image.raw_data + (dst_origin[0] * dst_desc.pixel_size); const size_t z_max = region[2]; const size_t y_max = region[1]; @@ -739,12 +740,13 @@ void libimg::HostCopyImage(const HostImage *src_image, HostImage *dst_image, for (size_t z = 0; z < z_max; z++) { const uint8_t *const src_slice = - src + (z + src_origin[2]) * src_desc.slice_pitch; - uint8_t *const dst_slice = dst + (z + dst_origin[2]) * dst_desc.slice_pitch; + src + ((z + src_origin[2]) * src_desc.slice_pitch); + uint8_t *const dst_slice = + dst + ((z + dst_origin[2]) * dst_desc.slice_pitch); for (size_t y = 0; y < y_max; y++) { const uint8_t *const src_row = - src_slice + (y + src_origin[1]) * src_desc.row_pitch; - uint8_t *dst_row = dst_slice + (y + dst_origin[1]) * dst_desc.row_pitch; + src_slice + ((y + src_origin[1]) * src_desc.row_pitch); + uint8_t *dst_row = dst_slice + ((y + dst_origin[1]) * dst_desc.row_pitch); std::memmove(dst_row, src_row, x_size); } } @@ -757,8 +759,8 @@ void libimg::HostCopyImageToBuffer(const HostImage *src_image, void *dst_buffer, const ImageMetaData &desc = src_image->image.meta_data; const uint8_t *const src = - src_image->image.raw_data + desc.pixel_size * src_origin[0] + - src_origin[1] * desc.row_pitch + src_origin[2] * desc.slice_pitch; + src_image->image.raw_data + (desc.pixel_size * src_origin[0]) + + (src_origin[1] * desc.row_pitch) + (src_origin[2] * desc.slice_pitch); uint8_t *const dst = static_cast(dst_buffer) + dst_offset; const size_t z_max = region[2]; @@ -767,7 +769,7 @@ void libimg::HostCopyImageToBuffer(const HostImage *src_image, void *dst_buffer, uint8_t *dst_row = dst; for (size_t z = 0; z < z_max; z++) { - const uint8_t *src_row = src + desc.slice_pitch * z; + const uint8_t *src_row = src + (desc.slice_pitch * z); for (size_t y = 0; y < y_max; y++) { std::memmove(dst_row, src_row, x_size); dst_row += x_size; diff --git a/modules/compiler/builtins/source/bakery.cpp.in b/modules/compiler/builtins/source/bakery.cpp.in index b80c304bb..f2fc02263 100644 --- a/modules/compiler/builtins/source/bakery.cpp.in +++ b/modules/compiler/builtins/source/bakery.cpp.in @@ -14,11 +14,11 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include + #include "builtins/bakery.h" #include "builtins/resources.h" -#include - namespace builtins { cargo::array_view get_api_src_file() { return rc::builtins::builtins_h; diff --git a/modules/compiler/compiler_pipeline/include/compiler/utils/mangling.h b/modules/compiler/compiler_pipeline/include/compiler/utils/mangling.h index cec95aeb0..087acd251 100644 --- a/modules/compiler/compiler_pipeline/include/compiler/utils/mangling.h +++ b/modules/compiler/compiler_pipeline/include/compiler/utils/mangling.h @@ -132,16 +132,16 @@ class TypeQualifiers final { StorageT storage_; /// @brief Number of bits used to encode the size of the list. - const static unsigned NumCountBits = 4; + static const unsigned NumCountBits = 4; /// @brief Number of bits used to encode one qualifier in the list. - const static unsigned NumQualBits = 10; + static const unsigned NumQualBits = 10; /// @brief Number of bits that can be used to store the list. - const static unsigned NumStorageBits = sizeof(StorageT) * 8; + static const unsigned NumStorageBits = sizeof(StorageT) * 8; /// @brief Maximum size of the list. - const static unsigned MaxSize = (NumStorageBits - NumCountBits) / NumQualBits; + static const unsigned MaxSize = (NumStorageBits - NumCountBits) / NumQualBits; static_assert(MaxSize < (1 << NumCountBits) - 1, "MaxSize cannot be encoded"); }; diff --git a/modules/compiler/compiler_pipeline/include/compiler/utils/sub_group_analysis.h b/modules/compiler/compiler_pipeline/include/compiler/utils/sub_group_analysis.h index fb19fc956..822bf9f7a 100644 --- a/modules/compiler/compiler_pipeline/include/compiler/utils/sub_group_analysis.h +++ b/modules/compiler/compiler_pipeline/include/compiler/utils/sub_group_analysis.h @@ -63,7 +63,7 @@ class GlobalSubgroupInfo { /// @brief Returns the SubgroupInfo for the provided function. /// /// The function must already exist in the map. - inline const SubgroupInfo *operator[](const llvm::Function *F) const { + const SubgroupInfo *operator[](const llvm::Function *F) const { const const_iterator I = FunctionMap.find(F); assert(I != FunctionMap.end() && "Function not in sub-group info!"); return I->second.get(); diff --git a/modules/compiler/compiler_pipeline/source/add_scheduling_parameters_pass.cpp b/modules/compiler/compiler_pipeline/source/add_scheduling_parameters_pass.cpp index 7e99fd9f2..29e428d8d 100644 --- a/modules/compiler/compiler_pipeline/source/add_scheduling_parameters_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/add_scheduling_parameters_pass.cpp @@ -85,9 +85,9 @@ PreservedAnalyses compiler::utils::AddSchedulingParametersPass::run( } } - LLVM_DEBUG(dbgs() << "Leaf functions requiring scheduling parameters:\n"; - for (auto *F - : Visited) { dbgs() << " " << F->getName() << "\n"; }); + LLVM_DEBUG( + dbgs() << "Leaf functions requiring scheduling parameters:\n"; + for (auto *F : Visited) { dbgs() << " " << F->getName() << "\n"; }); if (Visited.empty()) { return PreservedAnalyses::all(); @@ -152,7 +152,7 @@ PreservedAnalyses compiler::utils::AddSchedulingParametersPass::run( // Scrub any old subprogram - CloneFunctionInto will create a new one for // us - if (auto *const SP = OldF->getSubprogram()) { + if (OldF->getSubprogram()) { NewF->setSubprogram(nullptr); } diff --git a/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp b/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp index 63962f9b4..dd5a64c58 100644 --- a/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp @@ -640,7 +640,7 @@ void compiler::utils::AlignModuleStructsPass::fixupStructReferences() { // Iterate over all the structs in our map for (auto &mapItr : originalStructMap) { // Get the padding struct type and iterate over members - const ReplacementStructSP paddedStructDetails = mapItr.getSecond(); + const ReplacementStructSP &paddedStructDetails = mapItr.getSecond(); if (!paddedStructDetails) { continue; } diff --git a/modules/compiler/compiler_pipeline/source/barrier_regions.cpp b/modules/compiler/compiler_pipeline/source/barrier_regions.cpp index 97b035374..03118c52d 100644 --- a/modules/compiler/compiler_pipeline/source/barrier_regions.cpp +++ b/modules/compiler/compiler_pipeline/source/barrier_regions.cpp @@ -1050,8 +1050,7 @@ Function *compiler::utils::Barrier::GenerateNewKernel(BarrierRegion ®ion) { BasicBlock *entry_point = region.entry; LLVMContext &context = module_.getContext(); - LLVM_DEBUG(dbgs() << "\n"; unsigned i = 0; for (auto *d - : region.blocks) { + LLVM_DEBUG(dbgs() << "\n"; unsigned i = 0; for (auto *d : region.blocks) { dbgs() << "entry block: " << entry_point->getName() << "\n"; dbgs() << "region visited path [" << i++ << "] = " << d->getName() << "\n\n"; diff --git a/modules/compiler/compiler_pipeline/source/cl_builtin_info.cpp b/modules/compiler/compiler_pipeline/source/cl_builtin_info.cpp index b37eea39b..08f7ef2f8 100644 --- a/modules/compiler/compiler_pipeline/source/cl_builtin_info.cpp +++ b/modules/compiler/compiler_pipeline/source/cl_builtin_info.cpp @@ -1541,10 +1541,13 @@ Value *CLBuiltinInfo::emitBuiltinInline(Function *F, IRBuilder<> &B, return nullptr; } const bool IsSigned = *IsParamSignedOrNone; - const Intrinsic::ID IntrinsicOpc = - BuiltinID == eCLBuiltinSubSat - ? (IsSigned ? Intrinsic::ssub_sat : Intrinsic::usub_sat) - : (IsSigned ? Intrinsic::sadd_sat : Intrinsic::uadd_sat); + const Intrinsic::ID IntrinsicOpc = [=] { + if (BuiltinID == eCLBuiltinSubSat) { + return IsSigned ? Intrinsic::ssub_sat : Intrinsic::usub_sat; + } else { + return IsSigned ? Intrinsic::sadd_sat : Intrinsic::uadd_sat; + } + }(); return emitBuiltinInlineAsLLVMBinaryIntrinsic(B, Args[0], Args[1], IntrinsicOpc); } @@ -2621,7 +2624,7 @@ Value *CLBuiltinInfo::emitBuiltinInlineShuffle(BuiltinID BuiltinID, assert(Width != 3 && "Invalid vector width of 3!"); const int N = (Width == 3 ? 4 : Width); const int SignificantBits = - stdcompat::ilogb(2 * N - 1) + (isShuffle2 ? 1 : 0); + stdcompat::ilogb((2 * N) - 1) + (isShuffle2 ? 1 : 0); const unsigned BitMask = ~((~0u) << SignificantBits); Value *BitMaskV = ConstantVector::getSplat(ElementCount::getFixed(MaskWidth), ConstantInt::get(MaskTy, BitMask)); @@ -3171,8 +3174,7 @@ Instruction *CLBuiltinInfo::lowerGroupBuiltinToMuxBuiltin( SmallVector ArgumentTypes; SmallVector Qualifiers; - const auto DemangledName = std::string( - Mangler.demangleName(F->getName(), ArgumentTypes, Qualifiers)); + Mangler.demangleName(F->getName(), ArgumentTypes, Qualifiers); assert(Qualifiers.size() == 1 && ArgumentTypes.size() == 1 && "Unknown collective builtin"); @@ -3188,116 +3190,124 @@ Instruction *CLBuiltinInfo::lowerGroupBuiltinToMuxBuiltin( default: llvm_unreachable("unknown group operation for which to check the type"); case eMuxBuiltinSubgroupReduceAdd: - MuxBuiltinID = IsFP ? eMuxBuiltinSubgroupReduceFAdd : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupReduceFAdd; break; case eMuxBuiltinSubgroupReduceMul: - MuxBuiltinID = IsFP ? eMuxBuiltinSubgroupReduceFMul : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupReduceFMul; break; case eMuxBuiltinSubgroupReduceUMin: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupReduceFMin - : (IsSignedInt ? eMuxBuiltinSubgroupReduceSMin : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupReduceFMin; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupReduceSMin; + } break; case eMuxBuiltinSubgroupReduceUMax: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupReduceFMax - : (IsSignedInt ? eMuxBuiltinSubgroupReduceSMax : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupReduceFMax; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupReduceSMax; + } break; case eMuxBuiltinSubgroupScanAddInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupScanFAddInclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupScanFAddInclusive; break; case eMuxBuiltinSubgroupScanAddExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupScanFAddExclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupScanFAddExclusive; break; case eMuxBuiltinSubgroupScanMulInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupScanFMulInclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupScanFMulInclusive; break; case eMuxBuiltinSubgroupScanMulExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinSubgroupScanFMulExclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinSubgroupScanFMulExclusive; break; case eMuxBuiltinSubgroupScanUMinInclusive: - MuxBuiltinID = IsFP - ? eMuxBuiltinSubgroupScanFMinInclusive - : (IsSignedInt ? eMuxBuiltinSubgroupScanSMinInclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupScanFMinInclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupScanSMinInclusive; + } break; case eMuxBuiltinSubgroupScanUMinExclusive: - MuxBuiltinID = IsFP - ? eMuxBuiltinSubgroupScanFMinExclusive - : (IsSignedInt ? eMuxBuiltinSubgroupScanSMinExclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupScanFMinExclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupScanSMinExclusive; + } break; case eMuxBuiltinSubgroupScanUMaxInclusive: - MuxBuiltinID = IsFP - ? eMuxBuiltinSubgroupScanFMaxInclusive - : (IsSignedInt ? eMuxBuiltinSubgroupScanSMaxInclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupScanFMaxInclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupScanSMaxInclusive; + } break; case eMuxBuiltinSubgroupScanUMaxExclusive: - MuxBuiltinID = IsFP - ? eMuxBuiltinSubgroupScanFMaxExclusive - : (IsSignedInt ? eMuxBuiltinSubgroupScanSMaxExclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinSubgroupScanFMaxExclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinSubgroupScanSMaxExclusive; + } break; case eMuxBuiltinWorkgroupReduceAdd: - MuxBuiltinID = IsFP ? eMuxBuiltinWorkgroupReduceFAdd : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupReduceFAdd; break; case eMuxBuiltinWorkgroupReduceMul: - MuxBuiltinID = IsFP ? eMuxBuiltinWorkgroupReduceFMul : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupReduceFMul; break; case eMuxBuiltinWorkgroupReduceUMin: - MuxBuiltinID = IsFP ? eMuxBuiltinWorkgroupReduceFMin - : (IsSignedInt ? eMuxBuiltinWorkgroupReduceSMin - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupReduceFMin; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupReduceSMin; + } break; case eMuxBuiltinWorkgroupReduceUMax: - MuxBuiltinID = IsFP ? eMuxBuiltinWorkgroupReduceFMax - : (IsSignedInt ? eMuxBuiltinWorkgroupReduceSMax - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupReduceFMax; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupReduceSMax; + } break; case eMuxBuiltinWorkgroupScanAddInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFAddInclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupScanFAddInclusive; break; case eMuxBuiltinWorkgroupScanAddExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFAddExclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupScanFAddExclusive; break; case eMuxBuiltinWorkgroupScanMulInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMulInclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupScanFMulInclusive; break; case eMuxBuiltinWorkgroupScanMulExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMulExclusive : MuxBuiltinID; + if (IsFP) MuxBuiltinID = eMuxBuiltinWorkgroupScanFMulExclusive; break; case eMuxBuiltinWorkgroupScanUMinInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMinInclusive - : (IsSignedInt ? eMuxBuiltinWorkgroupScanSMinInclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanFMinInclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanSMinInclusive; + } break; case eMuxBuiltinWorkgroupScanUMinExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMinExclusive - : (IsSignedInt ? eMuxBuiltinWorkgroupScanSMinExclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanFMinExclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanSMinExclusive; + } break; case eMuxBuiltinWorkgroupScanUMaxInclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMaxInclusive - : (IsSignedInt ? eMuxBuiltinWorkgroupScanSMaxInclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanFMaxInclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanSMaxInclusive; + } break; case eMuxBuiltinWorkgroupScanUMaxExclusive: - MuxBuiltinID = - IsFP ? eMuxBuiltinWorkgroupScanFMaxExclusive - : (IsSignedInt ? eMuxBuiltinWorkgroupScanSMaxExclusive - : MuxBuiltinID); + if (IsFP) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanFMaxExclusive; + } else if (IsSignedInt) { + MuxBuiltinID = eMuxBuiltinWorkgroupScanSMaxExclusive; + } break; } } @@ -3416,9 +3426,13 @@ Instruction *CLBuiltinInfo::lowerAsyncBuiltinToMuxBuiltin( IsStrided ? ElementSize : B.CreateMul(ElementSize, NumElements, "width.bytes"); - const BuiltinID MuxBuiltinID = - IsRead ? (IsStrided ? eMuxBuiltinDMARead2D : eMuxBuiltinDMARead1D) - : (IsStrided ? eMuxBuiltinDMAWrite2D : eMuxBuiltinDMAWrite1D); + const BuiltinID MuxBuiltinID = [&] { + if (IsRead) { + return IsStrided ? eMuxBuiltinDMARead2D : eMuxBuiltinDMARead1D; + } else { + return IsStrided ? eMuxBuiltinDMAWrite2D : eMuxBuiltinDMAWrite1D; + } + }(); auto *const MuxDMA = BIMuxImpl.getOrDeclareMuxBuiltin(MuxBuiltinID, M, EventIn->getType()); diff --git a/modules/compiler/compiler_pipeline/source/degenerate_sub_group_pass.cpp b/modules/compiler/compiler_pipeline/source/degenerate_sub_group_pass.cpp index 82988d24d..1ee87e74a 100644 --- a/modules/compiler/compiler_pipeline/source/degenerate_sub_group_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/degenerate_sub_group_pass.cpp @@ -441,7 +441,7 @@ PreservedAnalyses compiler::utils::DegenerateSubGroupPass::run( Function *const NewF = cast(Mapped->second); assert(NewF && "Missing cloned function"); // Scrub any old subprogram - CloneFunctionInto will create a new one for us - if (auto *const SP = F->getSubprogram()) { + if (F->getSubprogram()) { NewF->setSubprogram(nullptr); } diff --git a/modules/compiler/compiler_pipeline/source/mux_builtin_info.cpp b/modules/compiler/compiler_pipeline/source/mux_builtin_info.cpp index 32c31877b..a84ee21df 100644 --- a/modules/compiler/compiler_pipeline/source/mux_builtin_info.cpp +++ b/modules/compiler/compiler_pipeline/source/mux_builtin_info.cpp @@ -39,7 +39,7 @@ namespace SchedParamIndices { enum { WI = 0, WG = 1, - TOTAL, + TOTAL = 2, }; } diff --git a/modules/compiler/compiler_pipeline/source/optimal_builtin_replacement_pass.cpp b/modules/compiler/compiler_pipeline/source/optimal_builtin_replacement_pass.cpp index dec9f0958..af89fc5f2 100644 --- a/modules/compiler/compiler_pipeline/source/optimal_builtin_replacement_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/optimal_builtin_replacement_pass.cpp @@ -232,7 +232,7 @@ PreservedAnalyses OptimalBuiltinReplacementPass::run(LazyCallGraph::SCC &C, [BI](CallBase &CB, StringRef, const SmallVectorImpl &, const SmallVectorImpl &) -> Value * { Function *Callee = CB.getCalledFunction(); - auto const Props = BI->analyzeBuiltin(*Callee).properties; + const auto Props = BI->analyzeBuiltin(*Callee).properties; if (Props & eBuiltinPropertyCanEmitInline) { IRBuilder<> B(&CB); const SmallVector Args(CB.args()); diff --git a/modules/compiler/compiler_pipeline/source/pass_functions.cpp b/modules/compiler/compiler_pipeline/source/pass_functions.cpp index 4bcf4f39c..43dea54c8 100644 --- a/modules/compiler/compiler_pipeline/source/pass_functions.cpp +++ b/modules/compiler/compiler_pipeline/source/pass_functions.cpp @@ -122,7 +122,7 @@ bool funcContainsDebugMetadata(const llvm::Function &func, for (auto &BB : func) { for (auto &Inst : BB) { - if (auto DL = Inst.getDebugLoc()) { + if (const auto &DL = Inst.getDebugLoc()) { llvm::DILocation *loc = DL.get(); vmap.MD()[loc].reset(loc); foundDI = true; @@ -689,7 +689,7 @@ llvm::Value *createBinOpForRecurKind(llvm::IRBuilderBase &B, llvm::Value *LHS, llvm::Value *RHS, llvm::RecurKind Kind) { switch (Kind) { default: - break; + llvm_unreachable("Unexpected Kind"); case llvm::RecurKind::None: return nullptr; case llvm::RecurKind::Add: @@ -702,29 +702,23 @@ llvm::Value *createBinOpForRecurKind(llvm::IRBuilderBase &B, llvm::Value *LHS, return B.CreateAnd(LHS, RHS); case llvm::RecurKind::Xor: return B.CreateXor(LHS, RHS); + case llvm::RecurKind::SMin: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::smin, LHS, RHS); + case llvm::RecurKind::UMin: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::umin, LHS, RHS); + case llvm::RecurKind::SMax: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::smax, LHS, RHS); + case llvm::RecurKind::UMax: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::umax, LHS, RHS); case llvm::RecurKind::FAdd: return B.CreateFAdd(LHS, RHS); case llvm::RecurKind::FMul: return B.CreateFMul(LHS, RHS); + case llvm::RecurKind::FMin: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::minnum, LHS, RHS); + case llvm::RecurKind::FMax: + return B.CreateBinaryIntrinsic(llvm::Intrinsic::maxnum, LHS, RHS); } - assert((Kind == llvm::RecurKind::FMin || Kind == llvm::RecurKind::FMax || - Kind == llvm::RecurKind::SMin || Kind == llvm::RecurKind::SMax || - Kind == llvm::RecurKind::UMin || Kind == llvm::RecurKind::UMax) && - "Unexpected min/max Kind"); - if (Kind == llvm::RecurKind::FMin || Kind == llvm::RecurKind::FMax) { - return B.CreateBinaryIntrinsic(Kind == llvm::RecurKind::FMin - ? llvm::Intrinsic::minnum - : llvm::Intrinsic::maxnum, - LHS, RHS); - } - const bool isMin = - Kind == llvm::RecurKind::SMin || Kind == llvm::RecurKind::UMin; - const bool isSigned = - Kind == llvm::RecurKind::SMin || Kind == llvm::RecurKind::SMax; - const llvm::Intrinsic::ID intrOpc = - isMin ? (isSigned ? llvm::Intrinsic::smin : llvm::Intrinsic::umin) - : (isSigned ? llvm::Intrinsic::smax : llvm::Intrinsic::umax); - return B.CreateBinaryIntrinsic(intrOpc, LHS, RHS); } } // namespace utils diff --git a/modules/compiler/compiler_pipeline/source/replace_local_module_scope_variables_pass.cpp b/modules/compiler/compiler_pipeline/source/replace_local_module_scope_variables_pass.cpp index d45cdd5fc..42e14bf8e 100644 --- a/modules/compiler/compiler_pipeline/source/replace_local_module_scope_variables_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/replace_local_module_scope_variables_pass.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -311,9 +312,7 @@ PreservedAnalyses compiler::utils::ReplaceLocalModuleScopeVariablesPass::run( assert(alignment > 0 && "'0' is an impossible alignment"); // check if this is the largest alignment seen so far - if (alignment > maxAlignment) { - maxAlignment = alignment; - } + maxAlignment = std::max(alignment, maxAlignment); // check if member is not already aligned const unsigned int remainder = offset % alignment; diff --git a/modules/compiler/compiler_pipeline/source/replace_target_ext_tys_pass.cpp b/modules/compiler/compiler_pipeline/source/replace_target_ext_tys_pass.cpp index 400bf6362..f09d23efd 100644 --- a/modules/compiler/compiler_pipeline/source/replace_target_ext_tys_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/replace_target_ext_tys_pass.cpp @@ -197,4 +197,3 @@ PreservedAnalyses compiler::utils::ReplaceTargetExtTysPass::run( return PreservedAnalyses::none(); } - diff --git a/modules/compiler/compiler_pipeline/source/work_item_loops_pass.cpp b/modules/compiler/compiler_pipeline/source/work_item_loops_pass.cpp index b1c6a5b89..074b1eb95 100644 --- a/modules/compiler/compiler_pipeline/source/work_item_loops_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/work_item_loops_pass.cpp @@ -1405,7 +1405,7 @@ Function *compiler::utils::WorkItemLoopsPass::makeWrapperFunction( // An inlinable function call in a function with debug info *must* be given // a debug location. DILocation *wrapperDbgLoc = nullptr; - if (auto *const SP = new_wrapper->getSubprogram()) { + if (new_wrapper->getSubprogram()) { wrapperDbgLoc = DILocation::get(context, /*line*/ 0, /*col*/ 0, new_wrapper->getSubprogram()); } diff --git a/modules/compiler/include/compiler/module.h b/modules/compiler/include/compiler/module.h index c0d7cc4d8..3386a9995 100644 --- a/modules/compiler/include/compiler/module.h +++ b/modules/compiler/include/compiler/module.h @@ -382,7 +382,7 @@ struct ProgramInfo { return true; } - inline size_t getNumKernels() const { return kernel_descriptions.size(); } + size_t getNumKernels() const { return kernel_descriptions.size(); } /// @brief Retrieve a kernel by index. /// diff --git a/modules/compiler/riscv/source/riscv_pass_machinery.cpp b/modules/compiler/riscv/source/riscv_pass_machinery.cpp index ccfbbbd1f..6c14605d6 100644 --- a/modules/compiler/riscv/source/riscv_pass_machinery.cpp +++ b/modules/compiler/riscv/source/riscv_pass_machinery.cpp @@ -142,8 +142,9 @@ RiscvPassMachinery::processOptimizationOptions( return env_var_opts; } -bool riscvVeczPassOpts(llvm::Function &F, llvm::ModuleAnalysisManager &AM, - llvm::SmallVectorImpl &PassOpts) { +static bool riscvVeczPassOpts( + llvm::Function &F, llvm::ModuleAnalysisManager &AM, + llvm::SmallVectorImpl &PassOpts) { auto vecz_mode = compiler::getVectorizationMode(F); if (!compiler::utils::isKernelEntryPt(F) || F.hasFnAttribute(llvm::Attribute::OptimizeNone) || diff --git a/modules/compiler/source/base/include/base/module.h b/modules/compiler/source/base/include/base/module.h index 3b730fbe5..b0aff102c 100644 --- a/modules/compiler/source/base/include/base/module.h +++ b/modules/compiler/source/base/include/base/module.h @@ -345,8 +345,7 @@ class BaseModule : public Module { /// /// @param[in] macro Macro definition to be added. /// @param[in,out] macro_defs List of macro defs to be added to. - inline void addMacroDef(const std::string ¯o, - MacroDefVec ¯o_defs) const { + void addMacroDef(const std::string ¯o, MacroDefVec ¯o_defs) const { macro_defs.emplace_back(MacroDefType::Def, macro); } @@ -355,8 +354,7 @@ class BaseModule : public Module { /// /// @param[in] macro Macro definition to be added as an undef. /// @param[in,out] macro_defs List of macro defs to be added to. - inline void addMacroUndef(const std::string ¯o, - MacroDefVec ¯o_defs) const { + void addMacroUndef(const std::string ¯o, MacroDefVec ¯o_defs) const { macro_defs.emplace_back(MacroDefType::Undef, macro); } @@ -364,8 +362,7 @@ class BaseModule : public Module { /// /// @param[in] opt OpenCL option to be added to clang. /// @param[in,out] opencl_opts List of options to be added to. - inline void addOpenCLOpt(const std::string &opt, - OpenCLOptVec &opencl_opts) const { + void addOpenCLOpt(const std::string &opt, OpenCLOptVec &opencl_opts) const { opencl_opts.emplace_back(opt); } diff --git a/modules/compiler/source/base/source/base_module_pass_machinery.cpp b/modules/compiler/source/base/source/base_module_pass_machinery.cpp index eb8efcbf9..9e463fcb1 100644 --- a/modules/compiler/source/base/source/base_module_pass_machinery.cpp +++ b/modules/compiler/source/base/source/base_module_pass_machinery.cpp @@ -107,7 +107,7 @@ void BaseModulePassMachinery::addClassToPassNames() { #include "base_module_pass_registry.def" } -Expected +static Expected parseAddKernelWrapperPassOptions(StringRef Params) { compiler::utils::AddKernelWrapperPassOptions Opts; @@ -135,7 +135,8 @@ parseAddKernelWrapperPassOptions(StringRef Params) { return Opts; } -Expected parseMakeFunctionNameUniquePassOptions(StringRef Params) { +static Expected parseMakeFunctionNameUniquePassOptions( + StringRef Params) { return compiler::utils::parseSinglePassStringRef(Params); } @@ -169,7 +170,7 @@ static ErrorOr, N>> parseIntList( constexpr const char LocalSizesOptName[] = "max-local-sizes="; constexpr const char GlobalSizesOptName[] = "max-global-sizes="; -Expected +static Expected parseEncodeBuiltinRangeMetadataPassOptions(StringRef Params) { compiler::utils::EncodeBuiltinRangeMetadataOptions Opts; while (!Params.empty()) { @@ -209,7 +210,7 @@ parseEncodeBuiltinRangeMetadataPassOptions(StringRef Params) { return Opts; } -Expected +static Expected parseEncodeKernelMetadataPassOptions(StringRef Params) { compiler::utils::EncodeKernelMetadataPassOptions Opts; while (!Params.empty()) { @@ -262,13 +263,13 @@ parseEncodeKernelMetadataPassOptions(StringRef Params) { return Opts; } -Expected parseReplaceMuxMathDeclsPassOptions(StringRef Params) { +static Expected parseReplaceMuxMathDeclsPassOptions(StringRef Params) { return compiler::utils::parseSinglePassOption(Params, "fast", "ReplaceMuxMathDeclsPass"); } // Lookup table for calling convention enums -std::unordered_map CallConvMap = { +static std::unordered_map CallConvMap = { {"C", CallingConv::C}, {"Fast", CallingConv::Fast}, {"Cold", CallingConv::Cold}, @@ -328,7 +329,7 @@ std::unordered_map CallConvMap = { // For parseFixupCallingConventionPassOptions we check the param against // an entry in a map. We should consider making this generic if we get similar // enum map style parsing needs -Expected parseFixupCallingConventionPassOptions( +static Expected parseFixupCallingConventionPassOptions( StringRef Params) { CallingConv::ID Result = CallingConv::C; while (!Params.empty()) { @@ -348,7 +349,7 @@ Expected parseFixupCallingConventionPassOptions( return Result; } -Expected +static Expected parseWorkItemLoopsPassOptions(StringRef Params) { compiler::utils::WorkItemLoopsPassOptions Opts; @@ -365,7 +366,7 @@ parseWorkItemLoopsPassOptions(StringRef Params) { return Opts; } -Expected> parseReduceToFunctionPassOptions( +static Expected> parseReduceToFunctionPassOptions( StringRef Params) { std::vector Names; @@ -395,7 +396,7 @@ Expected> parseReduceToFunctionPassOptions( return Names; } -Expected +static Expected parseReplaceTargetExtTysPassOptions(StringRef Params) { compiler::utils::ReplaceTargetExtTysOptions Opts; diff --git a/modules/compiler/source/base/source/printf_replacement_pass.cpp b/modules/compiler/source/base/source/printf_replacement_pass.cpp index 62dda56cb..e248f3bca 100644 --- a/modules/compiler/source/base/source/printf_replacement_pass.cpp +++ b/modules/compiler/source/base/source/printf_replacement_pass.cpp @@ -664,7 +664,7 @@ void compiler::PrintfReplacementPass::rewritePrintfCall( BasicBlock::Create(module.getContext(), "store", callFunction); // the buffer is the first argument of the function - Argument *full_buffer = static_cast(&*callFunction->arg_begin()); + Argument *full_buffer = (&*callFunction->arg_begin()); auto *buffer_elt_ty = getBufferEltTy(module.getContext()); diff --git a/modules/compiler/source/base/source/program_metadata.cpp b/modules/compiler/source/base/source/program_metadata.cpp index 1e1da0c2e..8231f3ab8 100644 --- a/modules/compiler/source/base/source/program_metadata.cpp +++ b/modules/compiler/source/base/source/program_metadata.cpp @@ -460,12 +460,11 @@ void populateAttributes(KernelInfo &kernel_info, llvm::MDNode *node) { llvm::MDNode *const subNode = llvm::cast(node->getOperand(i)); llvm::MDString *const operandName = llvm::cast(subNode->getOperand(0)); - if (!strcmp("reqd_work_group_size", operandName->getString().data())) { + if (operandName->getString() == "reqd_work_group_size") { populateRequiredWGSAttribute(kernel_info, subNode); - } else if (!strcmp("work_group_size_hint", - operandName->getString().data())) { + } else if (operandName->getString() == "work_group_size_hint") { populateWGSHintAttribute(kernel_info, subNode); - } else if (!strcmp("vec_type_hint", operandName->getString().data())) { + } else if (operandName->getString() == "vec_type_hint") { populateVectorTypeHintAttribute(kernel_info, subNode); } } diff --git a/modules/compiler/spirv-ll/include/spirv-ll/builder.h b/modules/compiler/spirv-ll/include/spirv-ll/builder.h index d8c392c3f..b59fcc9e9 100644 --- a/modules/compiler/spirv-ll/include/spirv-ll/builder.h +++ b/modules/compiler/spirv-ll/include/spirv-ll/builder.h @@ -627,7 +627,7 @@ class Builder { DEVICE = 4u, ALL_SVM_DEVICES = 5u, ALL_DEVICES = 6u, - MEM_FENCE_SCOPES_MAX + MEM_FENCE_SCOPES_MAX = 7u }; /// @brief Generate the mangled function name. diff --git a/modules/compiler/spirv-ll/include/spirv-ll/context.h b/modules/compiler/spirv-ll/include/spirv-ll/context.h index d0719fa2e..c2de4c353 100644 --- a/modules/compiler/spirv-ll/include/spirv-ll/context.h +++ b/modules/compiler/spirv-ll/include/spirv-ll/context.h @@ -112,7 +112,7 @@ struct SpecializationInfo { /// mismatch, then an error is reported. template cargo::expected getValue(spv::Id id) const { - static_assert(std::is_arithmetic::value, + static_assert(std::is_arithmetic_v, "Number must be an arithmetic type"); SPIRV_LL_ASSERT(isSpecialized(id), ("no specialization for " + std::to_string(id)).c_str()); diff --git a/modules/compiler/spirv-ll/include/spirv-ll/module.h b/modules/compiler/spirv-ll/include/spirv-ll/module.h index 688b0c927..e3eec2f8e 100644 --- a/modules/compiler/spirv-ll/include/spirv-ll/module.h +++ b/modules/compiler/spirv-ll/include/spirv-ll/module.h @@ -596,13 +596,13 @@ class Module : public ModuleHeader { /// @return Returns a pointer to the new `OpCode` derivative object. template const Op *create(const OpCode &opCode) { - static_assert(std::is_base_of::value, + static_assert(std::is_base_of_v, "Op must be derived from OpCode"); OpCodes.emplace_back(new Op(opCode)); SPIRV_LL_ASSERT(OpCodes.back()->code == Op::ClassCode, "mismatch between Op::ClassCode and OpCode::code"); const Op *op = static_cast(OpCodes.back().get()); - if (std::is_base_of::value) { + if (std::is_base_of_v) { resolveDecorations(reinterpret_cast(op)->IdResult()); } return op; diff --git a/modules/compiler/spirv-ll/source/builder_core.cpp b/modules/compiler/spirv-ll/source/builder_core.cpp index 0ecbd802e..45563aa74 100644 --- a/modules/compiler/spirv-ll/source/builder_core.cpp +++ b/modules/compiler/spirv-ll/source/builder_core.cpp @@ -379,7 +379,7 @@ llvm::Error Builder::create(const OpExtInstImport *op) { module.associateExtendedInstrSet(op->IdResult(), ExtendedInstrSet::OpenCLDebugInfo100); } else { - return makeStringError(llvm::Twine(name.data()) + + return makeStringError(name + " extended instruction set is not supported!\n"); } return llvm::Error::success(); @@ -2423,7 +2423,7 @@ llvm::Error Builder::create(const OpFunctionCall *op) { const unsigned n_args = op->wordCount() - 4; if (auto *const fn = module.getValue(op->Function())) { - callee = cast(module.getValue(op->Function())); + callee = cast(fn); } else { // If we haven't seen this function before (i.e., a forward reference), // create a call to an internal dummy function which we'll fix up during @@ -6260,12 +6260,10 @@ void Builder::generateReduction(const T *op, const std::string &opName, // Add in any required mangle information before we cache the reduction // wrapper. This is important for distinguishing between smin/smax, for // example. - const std::string cacheName = - (signInfo == MangleInfo::ForceSignInfo::ForceSigned - ? "s" - : (signInfo == MangleInfo::ForceSignInfo::ForceUnsigned ? "u" - : "")) + - opName; + const char *prefix = ""; + if (signInfo == MangleInfo::ForceSignInfo::ForceSigned) prefix = "s"; + if (signInfo == MangleInfo::ForceSignInfo::ForceUnsigned) prefix = "u"; + const std::string cacheName = prefix + opName; auto *&reductionWrapper = module.reductionWrapperMap[operation][cacheName] [module.getResultType(op->X())]; diff --git a/modules/compiler/spirv-ll/source/builder_debug_info.cpp b/modules/compiler/spirv-ll/source/builder_debug_info.cpp index 4de448dba..0fa30fd08 100644 --- a/modules/compiler/spirv-ll/source/builder_debug_info.cpp +++ b/modules/compiler/spirv-ll/source/builder_debug_info.cpp @@ -252,7 +252,8 @@ static std::unordered_map {167, llvm::dwarf::DW_OP_LLVM_tag_offset}, }; -llvm::DINode::DIFlags translateLRValueReferenceFlags(uint32_t spv_flags) { +static llvm::DINode::DIFlags translateLRValueReferenceFlags( + uint32_t spv_flags) { llvm::DINode::DIFlags flags = llvm::DINode::FlagZero; if (spv_flags & OpenCLDebugInfo100FlagLValueReference) { flags |= llvm::DINode::FlagLValueReference; @@ -263,7 +264,7 @@ llvm::DINode::DIFlags translateLRValueReferenceFlags(uint32_t spv_flags) { return flags; } -llvm::DINode::DIFlags translateAccessFlags(uint32_t spv_flags) { +static llvm::DINode::DIFlags translateAccessFlags(uint32_t spv_flags) { // This is a two-bit combination flag: // Protected: 1 << 0 // Private: 1 << 1 @@ -790,11 +791,12 @@ llvm::Expected DebugInfoBuilder::translate( if (auto err = size_or_error.takeError()) { return std::move(err); } + auto size = size_or_error.get(); // Without a size, we can't create a type. - if (!size_or_error.get()) { + if (!size) { return nullptr; } - const uint64_t size_in_bits = *size_or_error.get(); + const uint64_t size_in_bits = *size; if (spv_flags & OpenCLDebugInfo100FlagFwdDecl) { return dib.createForwardDecl(llvm::dwarf::DW_TAG_enumeration_type, *name, diff --git a/modules/compiler/spirv-ll/tools/spirv-ll.cpp b/modules/compiler/spirv-ll/tools/spirv-ll.cpp index f88f0ee91..cc8b97270 100644 --- a/modules/compiler/spirv-ll/tools/spirv-ll.cpp +++ b/modules/compiler/spirv-ll/tools/spirv-ll.cpp @@ -31,11 +31,11 @@ #include #include -int outputSpecConstants(spirv_ll::Context &spvContext, - llvm::ArrayRef spvCode, - llvm::raw_os_ostream &out); +static int outputSpecConstants(spirv_ll::Context &spvContext, + llvm::ArrayRef spvCode, + llvm::raw_os_ostream &out); -llvm::Expected getDeviceInfo( +static llvm::Expected getDeviceInfo( cargo::string_view api, cargo::array_view capabilities, cargo::array_view extensions, cargo::string_view bits, bool enableAll); diff --git a/modules/compiler/targets/host/source/HostPassMachinery.cpp b/modules/compiler/targets/host/source/HostPassMachinery.cpp index fd8d9895d..a68d4616a 100644 --- a/modules/compiler/targets/host/source/HostPassMachinery.cpp +++ b/modules/compiler/targets/host/source/HostPassMachinery.cpp @@ -55,8 +55,9 @@ namespace host { -bool hostVeczPassOpts(llvm::Function &F, llvm::ModuleAnalysisManager &MAM, - llvm::SmallVectorImpl &Opts) { +static bool hostVeczPassOpts( + llvm::Function &F, llvm::ModuleAnalysisManager &MAM, + llvm::SmallVectorImpl &Opts) { auto vecz_mode = compiler::getVectorizationMode(F); if (vecz_mode != compiler::VectorizationMode::ALWAYS && vecz_mode != compiler::VectorizationMode::AUTO) { @@ -136,7 +137,8 @@ void HostPassMachinery::addClassToPassNames() { /// @brief Helper functions for parsing options /// @note These functions are small but keep the def file simpler and is in line /// with PassBuilder.cpp -llvm::Expected parseFloatPointControlPassOptions(llvm::StringRef Params) { +static llvm::Expected parseFloatPointControlPassOptions( + llvm::StringRef Params) { return compiler::utils::parseSinglePassOption(Params, "ftz", "FloatPointControlPass"); } diff --git a/modules/compiler/targets/host/source/module.cpp b/modules/compiler/targets/host/source/module.cpp index a6fe7eeb7..575326ea9 100644 --- a/modules/compiler/targets/host/source/module.cpp +++ b/modules/compiler/targets/host/source/module.cpp @@ -314,7 +314,7 @@ void initializePassMachineryForFinalize( void HostModule::initializePassMachineryForFinalize( compiler::utils::PassMachinery &passMach) const { - return host::initializePassMachineryForFinalize(passMach, getHostTarget()); + host::initializePassMachineryForFinalize(passMach, getHostTarget()); } } // namespace host diff --git a/modules/compiler/test/group_ops.cpp b/modules/compiler/test/group_ops.cpp index 335d69de2..2495db00b 100644 --- a/modules/compiler/test/group_ops.cpp +++ b/modules/compiler/test/group_ops.cpp @@ -78,11 +78,9 @@ class GroupOpsTest : public CompilerLLVMModuleTest { }; static std::string getGroupBuiltinBaseName(GroupCollective::ScopeKind Scope) { - return std::string(Scope == GroupCollective::ScopeKind::SubGroup ? "sub" - : Scope == GroupCollective::ScopeKind::VectorGroup - ? "vec" - : "work") + - "_group_"; + if (Scope == GroupCollective::ScopeKind::SubGroup) return "sub_group_"; + if (Scope == GroupCollective::ScopeKind::VectorGroup) return "vec_group_"; + return "work_group_"; } std::vector getGroupBroadcasts(GroupCollective::ScopeKind Scope) { @@ -367,8 +365,11 @@ define void @test_wrapper(i32 %i, float %f, i32 %sg_lid, i64 %lid_x, i64 %lid_y, for (const auto &Op : GroupOps) { BuiltinDecls.push_back("declare " + Op.getLLVMFnString()); - const StringRef ParamName = - Op.LLVMTy == "float" ? "%f" : (Op.LLVMTy == "i32" ? "%i" : ""); + const StringRef ParamName = [&]() -> StringRef { + if (Op.LLVMTy == "float") return "%f"; + if (Op.LLVMTy == "i32") return "%i"; + return ""; + }(); BuiltinCalls.push_back("%call" + std::to_string(Idx) + " = call " + Op.getLLVMFnString(ParamName)); ++Idx; diff --git a/modules/compiler/tools/muxc/muxc.cpp b/modules/compiler/tools/muxc/muxc.cpp index c48da022d..50bbb6766 100644 --- a/modules/compiler/tools/muxc/muxc.cpp +++ b/modules/compiler/tools/muxc/muxc.cpp @@ -173,7 +173,7 @@ int main(int argc, char **argv) { namespace muxc { -uint32_t detectBuiltinCapabilities(mux_device_info_t device_info) { +static uint32_t detectBuiltinCapabilities(mux_device_info_t device_info) { uint32_t caps = 0; if (device_info->address_capabilities & mux_address_capabilities_bits32) { caps |= compiler::CAPS_32BIT; diff --git a/modules/compiler/utils/source/lld_linker.cpp b/modules/compiler/utils/source/lld_linker.cpp index ba474e675..0e1827cb8 100644 --- a/modules/compiler/utils/source/lld_linker.cpp +++ b/modules/compiler/utils/source/lld_linker.cpp @@ -113,6 +113,7 @@ Expected> lldLinkToBinary( "unable to open temporary object file"); } if (fwrite(rawBinary.data(), 1, rawBinary.size(), f) != rawBinary.size()) { + (void)fclose(f); return createStringError(inconvertibleErrorCode(), "unable to write binary to temporary object file"); } @@ -128,6 +129,7 @@ Expected> lldLinkToBinary( } if (fwrite(linkerScriptStr.c_str(), 1, linkerScriptStr.length(), fl) != linkerScriptStr.length()) { + (void)fclose(fl); return createStringError(inconvertibleErrorCode(), "unable to write to temporary linker script file"); } diff --git a/modules/compiler/utils/source/metadata_analysis.cpp b/modules/compiler/utils/source/metadata_analysis.cpp index a18bc01bd..066cfd015 100644 --- a/modules/compiler/utils/source/metadata_analysis.cpp +++ b/modules/compiler/utils/source/metadata_analysis.cpp @@ -24,7 +24,7 @@ namespace utils { AnalysisKey GenericMetadataAnalysis::Key; -Printable printGenericMD(const handler::GenericMetadata &MD) { +static Printable printGenericMD(const handler::GenericMetadata &MD) { return Printable([MD](raw_ostream &Out) { Out << "Kernel Name: " << MD.kernel_name << "\n"; Out << "Source Name: " << MD.source_name << "\n"; @@ -67,7 +67,7 @@ PreservedAnalyses GenericMetadataPrinterPass::run(Function &F, return PreservedAnalyses::all(); } -Printable printVectorizeMD(const handler::VectorizeInfoMetadata &MD) { +static Printable printVectorizeMD(const handler::VectorizeInfoMetadata &MD) { return Printable([MD](raw_ostream &Out) { Out << printGenericMD(MD); Out << "Min Work Width: " << print(MD.min_work_item_factor) << "\n"; diff --git a/modules/compiler/vecz/include/vecz/vecz_target_info.h b/modules/compiler/vecz/include/vecz/vecz_target_info.h index 3b66d2195..d922eb6e9 100644 --- a/modules/compiler/vecz/include/vecz/vecz_target_info.h +++ b/modules/compiler/vecz/include/vecz/vecz_target_info.h @@ -684,6 +684,12 @@ class TargetInfoAnalysis : public llvm::AnalysisInfoMixin { CallbackFn TICallback; }; +std::unique_ptr createTargetInfoArm(llvm::TargetMachine *tm); + +std::unique_ptr createTargetInfoAArch64(llvm::TargetMachine *tm); + +std::unique_ptr createTargetInfoRISCV(llvm::TargetMachine *tm); + /// @brief Create a new vector target info instance. /// @param[in] tm LLVM target machine that will be used for compilation, can /// be NULL if no target data is available. diff --git a/modules/compiler/vecz/source/analysis/liveness_analysis.cpp b/modules/compiler/vecz/source/analysis/liveness_analysis.cpp index 22d1b267f..d7ef1aecf 100644 --- a/modules/compiler/vecz/source/analysis/liveness_analysis.cpp +++ b/modules/compiler/vecz/source/analysis/liveness_analysis.cpp @@ -89,7 +89,7 @@ class LivenessResult::Impl { void calculateMaxRegistersInBlock(const llvm::BasicBlock *BB); // private utility method for code conciseness - inline BlockLivenessInfo &info(const BasicBlock *BB) const { + BlockLivenessInfo &info(const BasicBlock *BB) const { auto BIi = LR.BlockInfos.find(BB); assert(BIi != LR.BlockInfos.end() && "Block Liveness Info does not exist!"); return BIi->second; diff --git a/modules/compiler/vecz/source/analysis/stride_analysis.cpp b/modules/compiler/vecz/source/analysis/stride_analysis.cpp index de1f24c6a..745a3bd6f 100644 --- a/modules/compiler/vecz/source/analysis/stride_analysis.cpp +++ b/modules/compiler/vecz/source/analysis/stride_analysis.cpp @@ -102,13 +102,16 @@ PreservedAnalyses StrideAnalysisPrinterPass::run(Function &F, continue; } if (const OffsetInfo *Info = SAR.getInfo(Ptr)) { - OS << "* Stride for " << *Ptr << "\n"; - OS << " - " - << (Info->mayDiverge() - ? "divergent" - : (Info->hasStride() - ? "linear" - : (Info->isUniform() ? "uniform" : "unknown"))); + OS << "* Stride for " << *Ptr << "\n - "; + if (Info->mayDiverge()) { + OS << "divergent"; + } else if (Info->hasStride()) { + OS << "linear"; + } else if (Info->isUniform()) { + OS << "uniform"; + } else { + OS << "unknown"; + } if (Info->isStrideConstantInt()) { OS << " stride of " << Info->getStrideAsConstantInt(); } diff --git a/modules/compiler/vecz/source/analysis/vectorizable_function_analysis.cpp b/modules/compiler/vecz/source/analysis/vectorizable_function_analysis.cpp index 988f3208a..96ee366e8 100644 --- a/modules/compiler/vecz/source/analysis/vectorizable_function_analysis.cpp +++ b/modules/compiler/vecz/source/analysis/vectorizable_function_analysis.cpp @@ -36,7 +36,7 @@ llvm::AnalysisKey VectorizableFunctionAnalysis::Key; /// /// This flag is for testing and debugging purposes and it should not be used /// for normal code as instantiating undefined functions is not always valid. -cl::opt HandleDeclOnlyCalls( +static cl::opt HandleDeclOnlyCalls( "vecz-handle-declaration-only-calls", cl::desc("Go ahead and handle calls to declaration-only functions")); diff --git a/modules/compiler/vecz/source/include/analysis/divergence_analysis.h b/modules/compiler/vecz/source/include/analysis/divergence_analysis.h index 49d2eafa5..4350da506 100644 --- a/modules/compiler/vecz/source/include/analysis/divergence_analysis.h +++ b/modules/compiler/vecz/source/include/analysis/divergence_analysis.h @@ -105,7 +105,7 @@ struct BlockQueue { index_list indices; /// @brief Constructs an empty BlockQueue - BlockQueue(const DivergenceResult &dr) : DR(dr){}; + BlockQueue(const DivergenceResult &dr) : DR(dr) {}; /// @brief Constructs a BlockQueue from a set of blocks. BlockQueue(const DivergenceResult &dr, diff --git a/modules/compiler/vecz/source/include/transform/passes.h b/modules/compiler/vecz/source/include/transform/passes.h index a2d115a93..1af52bb29 100644 --- a/modules/compiler/vecz/source/include/transform/passes.h +++ b/modules/compiler/vecz/source/include/transform/passes.h @@ -74,7 +74,7 @@ class BuiltinInliningPass : public llvm::PassInfoMixin { /// however much simpler than LLVM's. class BasicMem2RegPass : public llvm::PassInfoMixin { public: - BasicMem2RegPass(){}; + BasicMem2RegPass() {}; /// @brief The entry point to the pass. /// @param[in,out] F Function to optimize. diff --git a/modules/compiler/vecz/source/ir_cleanup.cpp b/modules/compiler/vecz/source/ir_cleanup.cpp index b8bcf24c4..497cf0e89 100644 --- a/modules/compiler/vecz/source/ir_cleanup.cpp +++ b/modules/compiler/vecz/source/ir_cleanup.cpp @@ -131,8 +131,7 @@ void IRCleanup::deleteInstructions() { } // Remove remaining instructions from the list. - LLVM_DEBUG(for (Instruction *I - : InstructionsToDelete) { + LLVM_DEBUG(for (Instruction *I : InstructionsToDelete) { dbgs() << "vecz: could not delete " << *I << "\n"; }); InstructionsToDelete.clear(); diff --git a/modules/compiler/vecz/source/pass.cpp b/modules/compiler/vecz/source/pass.cpp index 8f90e78f1..0dc17a436 100644 --- a/modules/compiler/vecz/source/pass.cpp +++ b/modules/compiler/vecz/source/pass.cpp @@ -49,7 +49,7 @@ using namespace llvm; /// @brief Provide debug logging for Vecz's PassManager /// /// This flag is intended for testing and debugging purposes. -cl::opt DebugVeczPipeline( +static cl::opt DebugVeczPipeline( "debug-vecz-pipeline", cl::desc("Enable debug logging of the vecz PassManager")); @@ -57,7 +57,7 @@ cl::opt DebugVeczPipeline( /// /// This flag specifies a textual description of the optimization pass pipeline /// to run over the kernel. -cl::opt VeczPassPipeline( +static cl::opt VeczPassPipeline( "vecz-passes", cl::desc( "A textual description of the pass pipeline. To have analysis passes " diff --git a/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp b/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp index ed1a5f940..38de9799d 100644 --- a/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp +++ b/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp @@ -2952,7 +2952,7 @@ bool ControlFlowConversionState::Impl::blendInstructions() { PHINode *PHI = PHINode::Create(T, numPreds, opDef->getName() + ".merge"); multi_llvm::insertBefore(PHI, B->begin()); - auto const *const LTag = DR->getTag(B).loop; + const auto *const LTag = DR->getTag(B).loop; bool hasVisitedPred = false; for (BasicBlock *pred : predecessors(B)) { Value *incomingV = nullptr; diff --git a/modules/compiler/vecz/source/transform/interleaved_group_combine_pass.cpp b/modules/compiler/vecz/source/transform/interleaved_group_combine_pass.cpp index de1b2b5c1..9614bd6f4 100644 --- a/modules/compiler/vecz/source/transform/interleaved_group_combine_pass.cpp +++ b/modules/compiler/vecz/source/transform/interleaved_group_combine_pass.cpp @@ -275,9 +275,11 @@ PreservedAnalyses InterleavedGroupCombinePass::run( InterleavedOpInfo Info; const bool OpIsLoad = Op->isLoad(); - Info.Kind = OpIsLoad - ? (Mask ? eMaskedInterleavedLoad : eInterleavedLoad) - : (Mask ? eMaskedInterleavedStore : eInterleavedStore); + if (OpIsLoad) { + Info.Kind = Mask ? eMaskedInterleavedLoad : eInterleavedLoad; + } else { + Info.Kind = Mask ? eMaskedInterleavedStore : eInterleavedStore; + } Info.Op = CI; Info.Stride = Stride; Info.Removed = false; diff --git a/modules/compiler/vecz/source/transform/packetization_helpers.cpp b/modules/compiler/vecz/source/transform/packetization_helpers.cpp index dd444cbff..4afe43e37 100644 --- a/modules/compiler/vecz/source/transform/packetization_helpers.cpp +++ b/modules/compiler/vecz/source/transform/packetization_helpers.cpp @@ -123,7 +123,7 @@ IRBuilder<> buildAfter(Value *V, Function &F, bool IsPhi) { return {&F.getEntryBlock(), it}; } -Constant *getShuffleMask(ShuffleVectorInst *shuffle) { +static Constant *getShuffleMask(ShuffleVectorInst *shuffle) { // The mask value seems not to be a proper operand for LLVM 11. // NOTE this is marked as "temporary" in the docs! return shuffle->getShuffleMaskForBitcode(); @@ -520,7 +520,8 @@ void Packetizer::Result::getPacketValues(SmallVectorImpl &vals) const { assert(info && "No packet info for this packetization result"); const auto width = info->numInstances; if (width != 0) { - return getPacketValues(width, vals); + getPacketValues(width, vals); + return; } } diff --git a/modules/compiler/vecz/source/transform/packetizer.cpp b/modules/compiler/vecz/source/transform/packetizer.cpp index 287e51508..69da33329 100644 --- a/modules/compiler/vecz/source/transform/packetizer.cpp +++ b/modules/compiler/vecz/source/transform/packetizer.cpp @@ -1124,7 +1124,7 @@ unsigned Packetizer::Impl::getPacketWidthForType(Type *ty, // Note that we don't really expect huge values here, over 16 is still // currently not officially supported, over 256 would be astonishing, // and over 65536 would be inconcievable, so we don't bother to >> 16. - unsigned width = fullWidth / maxWidth - 1; + unsigned width = (fullWidth / maxWidth) - 1; width |= width >> 1; width |= width >> 2; width |= width >> 4; @@ -3997,7 +3997,7 @@ ValuePacket Packetizer::Impl::packetizeShuffleVector( const auto adjust = isa(srcB) ? -scalarWidth : (width - 1) * scalarWidth; for (auto &idx : mask) { - if (idx != int(-1) && idx >= int(scalarWidth)) { + if (idx != -1 && idx >= int(scalarWidth)) { idx += adjust; } } @@ -4008,7 +4008,7 @@ ValuePacket Packetizer::Impl::packetizeShuffleVector( for (unsigned i = 1, k = 0; i < width; ++i, k += size) { for (unsigned j = 0; j < size; ++j) { auto maskElem = mask[k + j]; - if (maskElem != int(-1)) { + if (maskElem != -1) { maskElem += scalarWidth; } mask.push_back(maskElem); diff --git a/modules/compiler/vecz/source/transform/printf_scalarizer.cpp b/modules/compiler/vecz/source/transform/printf_scalarizer.cpp index ff544ff69..aa8ffedce 100644 --- a/modules/compiler/vecz/source/transform/printf_scalarizer.cpp +++ b/modules/compiler/vecz/source/transform/printf_scalarizer.cpp @@ -75,7 +75,7 @@ std::string GetFormatStringAsString(Value *op) { return array_string->getAsString().str(); } -bool IncrementPtr(const char **fmt) { +static bool IncrementPtr(const char **fmt) { if (*(++(*fmt)) == '\0') { return true; } diff --git a/modules/compiler/vecz/source/transform/scalarizer.cpp b/modules/compiler/vecz/source/transform/scalarizer.cpp index a95910f6e..b812d5b37 100644 --- a/modules/compiler/vecz/source/transform/scalarizer.cpp +++ b/modules/compiler/vecz/source/transform/scalarizer.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "debugging.h" #include "llvm_helpers.h" #include "memory_operations.h" @@ -834,9 +836,7 @@ SimdPacket *Scalarizer::scalarizeLoad(LoadInst *Load, PacketMask PM) { // whole vector. const unsigned Alignment = Load->getAlign().value(); unsigned EleAlign = ScalarEleTy->getPrimitiveSizeInBits() / 8; - if (Alignment < EleAlign) { - EleAlign = Alignment; - } + EleAlign = std::min(Alignment, EleAlign); // Emit scalarized loads. for (unsigned i = 0; i < SimdWidth; i++) { @@ -919,9 +919,7 @@ SimdPacket *Scalarizer::scalarizeStore(StoreInst *Store, PacketMask PM) { // See comment at equivalent part of scalarizeLoad() const unsigned Alignment = Store->getAlign().value(); unsigned EleAlign = ScalarEleTy->getPrimitiveSizeInBits() / 8; - if (Alignment < EleAlign) { - EleAlign = Alignment; - } + EleAlign = std::min(Alignment, EleAlign); // Emit scalarized stores. for (unsigned i = 0; i < SimdWidth; i++) { @@ -1133,9 +1131,9 @@ SimdPacket *Scalarizer::scalarizeBitCast(BitCastInst *BC, PacketMask PM) { SrcPart = B.CreateZExt(SrcPart, DstEleIntTy); } if (i * DstEleSize > j * SrcEleSize) { - SrcPart = B.CreateLShr(SrcPart, i * DstEleSize - j * SrcEleSize); + SrcPart = B.CreateLShr(SrcPart, (i * DstEleSize) - (j * SrcEleSize)); } else if (j * SrcEleSize > i * DstEleSize) { - SrcPart = B.CreateShl(SrcPart, j * SrcEleSize - i * DstEleSize); + SrcPart = B.CreateShl(SrcPart, (j * SrcEleSize) - (i * DstEleSize)); } if (SrcEleIntTy->getIntegerBitWidth() > DstEleIntTy->getIntegerBitWidth()) { @@ -1311,9 +1309,7 @@ SimdPacket *Scalarizer::scalarizeMaskedMemOp(CallInst *CI, PacketMask PM, const unsigned Alignment = MaskedOp.getAlignment(); unsigned EleAlign = ScalarEleTy->getPrimitiveSizeInBits() / 8; - if (Alignment < EleAlign) { - EleAlign = Alignment; - } + EleAlign = std::min(Alignment, EleAlign); for (unsigned i = 0; i < SimdWidth; i++) { if (!PM.isEnabled(i) || P->at(i)) { diff --git a/modules/compiler/vecz/source/vector_target_info.cpp b/modules/compiler/vecz/source/vector_target_info.cpp index 78c223bb7..172c6317c 100644 --- a/modules/compiler/vecz/source/vector_target_info.cpp +++ b/modules/compiler/vecz/source/vector_target_info.cpp @@ -1331,14 +1331,6 @@ bool TargetInfo::canPacketize(const llvm::Value *, ElementCount) const { return true; } -namespace vecz { -std::unique_ptr createTargetInfoArm(TargetMachine *tm); - -std::unique_ptr createTargetInfoAArch64(TargetMachine *tm); - -std::unique_ptr createTargetInfoRISCV(TargetMachine *tm); -} // namespace vecz - std::unique_ptr vecz::createTargetInfoFromTargetMachine( TargetMachine *tm) { // The TargetMachine is allowed to be null diff --git a/modules/compiler/vecz/source/vector_target_info_riscv.cpp b/modules/compiler/vecz/source/vector_target_info_riscv.cpp index 748991d55..e1a42789c 100644 --- a/modules/compiler/vecz/source/vector_target_info_riscv.cpp +++ b/modules/compiler/vecz/source/vector_target_info_riscv.cpp @@ -746,9 +746,8 @@ Value *TargetInfoRISCV::createVPKernelWidth(IRBuilder<> &B, auto *const I32Ty = Type::getInt32Ty(B.getContext()); auto *const I64Ty = Type::getInt64Ty(B.getContext()); - auto *const VL = - B.CreateIntrinsic(Intrinsic::RISCVIntrinsics::riscv_vsetvli, {I64Ty}, - {RemainingIters, VSEW, VLMul}); + auto *const VL = B.CreateIntrinsic(Intrinsic::RISCVIntrinsics::riscv_vsetvli, + {I64Ty}, {RemainingIters, VSEW, VLMul}); return B.CreateTrunc(VL, I32Ty); } diff --git a/modules/compiler/vecz/source/vectorization_context.cpp b/modules/compiler/vecz/source/vectorization_context.cpp index 23ac15927..c1a735bb3 100644 --- a/modules/compiler/vecz/source/vectorization_context.cpp +++ b/modules/compiler/vecz/source/vectorization_context.cpp @@ -502,7 +502,7 @@ VectorizationContext::isMaskedAtomicFunction(const Function &F) const { if (IsCmpXchg) { if (auto Ordering = demangleOrdering()) { - AtomicInfo.CmpXchgFailureOrdering = *Ordering; + AtomicInfo.CmpXchgFailureOrdering = Ordering; } else { return std::nullopt; } @@ -1115,10 +1115,14 @@ bool VectorizationContext::emitMaskedAtomicBody( Value *const IdxStart = B.getInt32(0); ConstantInt *const KnownMin = B.getInt32(MA.VF.getKnownMinValue()); - Value *IdxEnd = - MA.IsVectorPredicated - ? F.getArg(3 + IsCmpXchg) - : (!MA.VF.isScalable() ? KnownMin : B.CreateVScale(KnownMin)); + Value *IdxEnd; + if (MA.IsVectorPredicated) { + IdxEnd = F.getArg(3 + IsCmpXchg); + } else if (MA.VF.isScalable()) { + IdxEnd = B.CreateVScale(KnownMin); + } else { + IdxEnd = KnownMin; + } Value *RetVal = nullptr; Value *RetSuccessVal = nullptr; diff --git a/modules/compiler/vecz/source/vectorization_heuristics.cpp b/modules/compiler/vecz/source/vectorization_heuristics.cpp index beed2b6f3..5859fbfff 100644 --- a/modules/compiler/vecz/source/vectorization_heuristics.cpp +++ b/modules/compiler/vecz/source/vectorization_heuristics.cpp @@ -295,7 +295,7 @@ bool Heuristics::shouldVectorize() { } else if (CallInst *CI = dyn_cast(&I)) { const compiler::utils::BuiltinInfo &BI = Ctx.builtins(); if (Function *Callee = CI->getCalledFunction()) { - auto const builtin = BI.analyzeBuiltin(*Callee); + const auto builtin = BI.analyzeBuiltin(*Callee); if (!(builtin.properties & compiler::utils::eBuiltinPropertyWorkItem)) { weight++; diff --git a/modules/compiler/vecz/source/vectorizer.cpp b/modules/compiler/vecz/source/vectorizer.cpp index 8c90389ef..41feec41b 100644 --- a/modules/compiler/vecz/source/vectorizer.cpp +++ b/modules/compiler/vecz/source/vectorizer.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -166,9 +167,8 @@ void collectStatistics(VectorizationUnit &VU, Function *Scalar, ScalarVectorInsts += isVectorInst(I); // Find out how wide is the widest vector used in the scalar kernel if (auto *VecTy = dyn_cast(I.getType())) { - if (VecTy->getNumElements() > MaxScalarVectorWidth) { - MaxScalarVectorWidth = VecTy->getNumElements(); - } + MaxScalarVectorWidth = + std::max(VecTy->getNumElements(), MaxScalarVectorWidth); } } } diff --git a/modules/compiler/vecz/source/vecz_pass_builder.cpp b/modules/compiler/vecz/source/vecz_pass_builder.cpp index bcb8f3e15..f1a110b45 100644 --- a/modules/compiler/vecz/source/vecz_pass_builder.cpp +++ b/modules/compiler/vecz/source/vecz_pass_builder.cpp @@ -140,7 +140,7 @@ void VeczPassMachinery::addClassToPassNames() { // FIXME: This is repeating the job of the VectorizationUnitAnalysis. // We should track 'failure' more directly in the // Function/VectorizationContext? - auto const *const VU = Ctx.getActiveVU(F); + const auto *const VU = Ctx.getActiveVU(F); if (!VU) { // Don't run on anything without a VU since it's not currently being // vectorized. diff --git a/modules/kts/include/kts/arguments_shared.h b/modules/kts/include/kts/arguments_shared.h index 5be6bc8ba..d3590155a 100644 --- a/modules/kts/include/kts/arguments_shared.h +++ b/modules/kts/include/kts/arguments_shared.h @@ -459,7 +459,7 @@ template struct MemoryAccessor { T LoadFromBuffer(void *Ptr, size_t Offset) { void *const PtrPlusOffset = - static_cast(Ptr) + Offset * sizeof(T); + static_cast(Ptr) + (Offset * sizeof(T)); T Val; memcpy(&Val, PtrPlusOffset, sizeof(T)); return Val; @@ -467,7 +467,7 @@ struct MemoryAccessor { void StoreToBuffer(const T &Val, void *Ptr, size_t Offset) { void *const PtrPlusOffset = - static_cast(Ptr) + Offset * sizeof(T); + static_cast(Ptr) + (Offset * sizeof(T)); memcpy(PtrPlusOffset, &Val, sizeof(T)); } }; diff --git a/modules/loader/include/loader/elf.h b/modules/loader/include/loader/elf.h index 5b2219534..95c053bb8 100644 --- a/modules/loader/include/loader/elf.h +++ b/modules/loader/include/loader/elf.h @@ -214,17 +214,17 @@ class ElfFile { /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline ElfFields::Type type() const { + ElfFields::Type type() const { return field(is32Bit() ? header32()->type : header64()->type); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline ElfFields::Machine machine() const { + ElfFields::Machine machine() const { return field(is32Bit() ? header32()->machine : header64()->machine); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint32_t flags() const { + uint32_t flags() const { return field(is32Bit() ? header32()->flags : header64()->flags); } @@ -275,24 +275,24 @@ class ElfFile { /// @brief Wrapper for a section in the ELF file. struct Section { - inline Section() : file(nullptr), header(nullptr) {} + Section() : file(nullptr), header(nullptr) {} /// @brief Constructs the object with the section header starting at ptr. - inline Section(ElfFile *file, const void *ptr) : file(file), header(ptr) {} + Section(ElfFile *file, const void *ptr) : file(file), header(ptr) {} ElfFile *file; const void *header; /// @brief Gets the ELF32 section header. - inline const SectionHeader32 *header32() const { + const SectionHeader32 *header32() const { return reinterpret_cast(header); } /// @brief Gets the ELF64 section header. - inline const SectionHeader64 *header64() const { + const SectionHeader64 *header64() const { return reinterpret_cast(header); } /// @brief Gets the index of this section in the section header table. - inline uint32_t index() const { + uint32_t index() const { auto sht_entry_size = static_cast( file->is32Bit() ? file->field(file->header32()->sht_entry_size) : file->field(file->header64()->sht_entry_size)); @@ -306,42 +306,42 @@ class ElfFile { const cargo::string_view name() const; /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline ElfFields::SectionType type() const { + ElfFields::SectionType type() const { return file->field(file->is32Bit() ? header32()->type : header64()->type); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline ElfFields::SectionFlags::Type flags() const { + ElfFields::SectionFlags::Type flags() const { return static_cast( file->field(file->is32Bit() ? header32()->flags : header64()->flags)); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint64_t virtual_address() const { + uint64_t virtual_address() const { return file->field(file->is32Bit() ? header32()->virtual_address : header64()->virtual_address); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint64_t file_offset() const { + uint64_t file_offset() const { return file->field(file->is32Bit() ? header32()->file_offset : header64()->file_offset); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint64_t size() const { + uint64_t size() const { return file->field(file->is32Bit() ? header32()->size : header64()->size); } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint64_t entrySize() const { + uint64_t entrySize() const { return file->field(file->is32Bit() ? header32()->entry_size : header64()->entry_size); } /// @brief Returns an estimate of what size to allocate for section, may be /// different from size() because relocations may need generated stubs. - inline uint64_t sizeToAlloc() const { + uint64_t sizeToAlloc() const { if (file->machine() == ElfFields::Machine::X86 || file->machine() == ElfFields::Machine::X86_64) { // no need to write new code on x86 - all relocations fit into target @@ -356,7 +356,7 @@ class ElfFile { } /// @brief Gets a view of the bytes in this section. - inline const cargo::array_view data() const { + const cargo::array_view data() const { CARGO_ASSERT(type() != ElfFields::SectionType::NOBITS, "Trying to get a data view for a nobits section."); const size_t offset = file->field( @@ -365,7 +365,7 @@ class ElfFile { } /// @brief Field accessors, choosing the right bitness and converting /// endianness if needed. - inline uint64_t alignment() const { + uint64_t alignment() const { return file->field(file->is32Bit() ? header32()->alignment : header64()->alignment); } @@ -373,19 +373,19 @@ class ElfFile { /// @brief Wrapper for a symbol in the ELF file. struct Symbol { - inline Symbol() : file(nullptr), entry(nullptr) {} + Symbol() : file(nullptr), entry(nullptr) {} /// @brief Constructs the object with the symbol entry starting at ptr. - inline Symbol(ElfFile *file, const void *ptr) : file(file), entry(ptr) {} + Symbol(ElfFile *file, const void *ptr) : file(file), entry(ptr) {} ElfFile *file; const void *entry; /// @brief Gets the ELF32 symbol entry. - inline const Symbol32 *symbol32() const { + const Symbol32 *symbol32() const { return reinterpret_cast(entry); } /// @brief Gets the ELF64 symbol entry. - inline const Symbol64 *symbol64() const { + const Symbol64 *symbol64() const { return reinterpret_cast(entry); } @@ -440,28 +440,28 @@ class ElfFile { /// @brief Gets the identification part of the ELF header, shared across both /// ELF formats. - inline const HeaderIdent *headerIdent() const { + const HeaderIdent *headerIdent() const { return reinterpret_cast(bytes.begin()); } /// @brief Gets the ELF32 file header. - inline const Header32 *header32() const { + const Header32 *header32() const { return reinterpret_cast(bytes.begin()); } /// @brief Gets the ELF64 file header. - inline const Header64 *header64() const { + const Header64 *header64() const { return reinterpret_cast(bytes.begin()); } /// @brief Checks if the ELF file is in the 32-bit format. - inline bool is32Bit() const { + bool is32Bit() const { CARGO_ASSERT(!bytes.empty(), "Using a null ElfFile instance"); return headerIdent()->bitness == ElfFields::Bitness::B32; } /// @brief Gets the number of sections in the ELF file. - inline size_t sectionCount() const { + size_t sectionCount() const { return static_cast(is32Bit() ? header32()->sht_entry_count : header64()->sht_entry_count); } @@ -479,7 +479,7 @@ class ElfFile { SectionIteratorPair sections(); /// @brief Gets the number of symbols in the ELF file. - inline size_t symbolCount() const { + size_t symbolCount() const { return static_cast(symbol_section ? symbol_section->size() / symbol_section->entrySize() : 0); @@ -500,7 +500,7 @@ class ElfFile { /// @brief Use this wrapper if reading directly from ELF structures, it /// converts the values in memory to the right endianness for the CPU. template - inline std::enable_if_t, Integer> field( + std::enable_if_t, Integer> field( Integer v) const { CARGO_ASSERT(!bytes.empty(), "Using a null ElfFile instance"); return (headerIdent()->endianness == (cargo::is_little_endian() @@ -513,8 +513,7 @@ class ElfFile { /// @brief Use this wrapper if reading directly from ELF structures, it /// converts the values in memory to the right endianness for the CPU. template >> - inline std::enable_if_t>, - Enum> + std::enable_if_t>, Enum> field(Enum v) const { using Integer = std::underlying_type_t; CARGO_ASSERT(!bytes.empty(), "Using a null ElfFile instance"); @@ -550,19 +549,19 @@ struct ElfMap { uint64_t target_address; }; - inline ElfMap() : file(nullptr) {} - inline ElfMap(ElfFile *file) : file(file) {} + ElfMap() : file(nullptr) {} + ElfMap(ElfFile *file) : file(file) {} /// @brief The symbol mappings iterators. - inline Mapping *sectionMappingsBegin() { return sectionMappings.begin(); } + Mapping *sectionMappingsBegin() { return sectionMappings.begin(); } /// @brief The symbol mappings iterators. - inline Mapping *sectionMappingsEnd() { return sectionMappings.end(); } + Mapping *sectionMappingsEnd() { return sectionMappings.end(); } /// @brief Adds a new ELF section mapping. - inline cargo::result addSectionMapping(const ElfFile::Section §ion, - uint8_t *writable_address, - uint8_t *writable_end, - uint64_t target_address) { + cargo::result addSectionMapping(const ElfFile::Section §ion, + uint8_t *writable_address, + uint8_t *writable_end, + uint64_t target_address) { return sectionMappings.push_back({section.index(), writable_address, writable_address + section.size(), writable_end, target_address}); @@ -570,8 +569,8 @@ struct ElfMap { /// @brief Adds a new callback, which allows to define undefined symbols that /// are present outside of the ELF file. - [[nodiscard]] inline cargo::result addCallback(cargo::string_view name, - uint64_t target_address) { + [[nodiscard]] cargo::result addCallback(cargo::string_view name, + uint64_t target_address) { return callbacks.push_back( {std::string{name.data(), name.size()}, target_address}); } @@ -607,8 +606,7 @@ struct ElfMap { // Note that `symbol()` only performs bounds checking in debug builds, so // further checks may be required if this function is used in non-debug // builds. - inline cargo::optional getSymbolName( - uint32_t index) const { + cargo::optional getSymbolName(uint32_t index) const { return file->symbol(index).name(); } #endif @@ -624,32 +622,31 @@ struct SectionIterator { ElfFile *file; size_t index; - inline SectionIterator(ElfFile *file, size_t index = 0) - : file(file), index(index) {} + SectionIterator(ElfFile *file, size_t index = 0) : file(file), index(index) {} - inline SectionIterator &operator++() { + SectionIterator &operator++() { ++index; return *this; } - inline SectionIterator operator++(int) { + SectionIterator operator++(int) { SectionIterator old = *this; ++index; return old; } - inline SectionIterator &operator--() { + SectionIterator &operator--() { --index; return *this; } - inline SectionIterator operator--(int) { + SectionIterator operator--(int) { SectionIterator old = *this; --index; return old; } - inline ElfFile::Section &operator*() { + ElfFile::Section &operator*() { CARGO_ASSERT(file != nullptr, "Section iterator using a null ElfFile instance"); CARGO_ASSERT(index < file->sectionCount(), @@ -658,17 +655,17 @@ struct SectionIterator { return current; } - inline ElfFile::Section &operator->() { return operator*(); } + ElfFile::Section &operator->() { return operator*(); } - inline bool operator==(const SectionIterator &rhs) { + bool operator==(const SectionIterator &rhs) { return rhs.file == file && rhs.index == index; } - inline bool operator!=(const SectionIterator &rhs) { + bool operator!=(const SectionIterator &rhs) { return rhs.file != file || rhs.index != index; } - inline void updateCurrent() { current = file->section(index); } + void updateCurrent() { current = file->section(index); } private: ElfFile::Section current; @@ -679,32 +676,31 @@ struct SymbolIterator { ElfFile *file; size_t index; - inline SymbolIterator(ElfFile *file, size_t index = 0) - : file(file), index(index) {} + SymbolIterator(ElfFile *file, size_t index = 0) : file(file), index(index) {} - inline SymbolIterator &operator++() { + SymbolIterator &operator++() { ++index; return *this; } - inline SymbolIterator operator++(int) { + SymbolIterator operator++(int) { SymbolIterator old = *this; ++index; return old; } - inline SymbolIterator &operator--() { + SymbolIterator &operator--() { --index; return *this; } - inline SymbolIterator operator--(int) { + SymbolIterator operator--(int) { SymbolIterator old = *this; --index; return old; } - inline ElfFile::Symbol &operator*() { + ElfFile::Symbol &operator*() { CARGO_ASSERT(file != nullptr, "Symbol iterator using a null ElfFile instance"); CARGO_ASSERT(index < file->symbolCount(), "Symbol iterator out of bounds"); @@ -712,17 +708,17 @@ struct SymbolIterator { return current; } - inline ElfFile::Symbol &operator->() { return operator*(); } + ElfFile::Symbol &operator->() { return operator*(); } - inline bool operator==(const SymbolIterator &rhs) { + bool operator==(const SymbolIterator &rhs) { return rhs.file == file && rhs.index == index; } - inline bool operator!=(const SymbolIterator &rhs) { + bool operator!=(const SymbolIterator &rhs) { return rhs.file != file || rhs.index != index; } - inline void updateCurrent() { current = file->symbol(index); } + void updateCurrent() { current = file->symbol(index); } private: ElfFile::Symbol current; @@ -730,14 +726,14 @@ struct SymbolIterator { /// @brief Wraps the begin and end section iterators to allow range for loops. struct SectionIteratorPair { - inline SectionIteratorPair(SectionIterator beginIter, SectionIterator endIter) + SectionIteratorPair(SectionIterator beginIter, SectionIterator endIter) : beginIter(beginIter), endIter(endIter) {} - inline SectionIterator &begin() { return beginIter; } - inline const SectionIterator &begin() const { return beginIter; } + SectionIterator &begin() { return beginIter; } + const SectionIterator &begin() const { return beginIter; } - inline SectionIterator &end() { return endIter; } - inline const SectionIterator &end() const { return endIter; } + SectionIterator &end() { return endIter; } + const SectionIterator &end() const { return endIter; } SectionIterator beginIter; SectionIterator endIter; @@ -745,14 +741,14 @@ struct SectionIteratorPair { /// @brief Wraps the begin and end section iterators to allow range for loops. struct SymbolIteratorPair { - inline SymbolIteratorPair(SymbolIterator beginIter, SymbolIterator endIter) + SymbolIteratorPair(SymbolIterator beginIter, SymbolIterator endIter) : beginIter(beginIter), endIter(endIter) {} - inline SymbolIterator &begin() { return beginIter; } - inline const SymbolIterator &begin() const { return beginIter; } + SymbolIterator &begin() { return beginIter; } + const SymbolIterator &begin() const { return beginIter; } - inline SymbolIterator &end() { return endIter; } - inline const SymbolIterator &end() const { return endIter; } + SymbolIterator &end() { return endIter; } + const SymbolIterator &end() const { return endIter; } SymbolIterator beginIter; SymbolIterator endIter; diff --git a/modules/loader/include/loader/mapper.h b/modules/loader/include/loader/mapper.h index 4a7842c4a..f1048b31f 100644 --- a/modules/loader/include/loader/mapper.h +++ b/modules/loader/include/loader/mapper.h @@ -63,9 +63,7 @@ struct PageRange { cargo::result protect(MemoryProtection protection); /// @brief Gets the allocated memory range. - inline cargo::array_view data() const { - return {pages_begin, pages_end}; - } + cargo::array_view data() const { return {pages_begin, pages_end}; } private: uint8_t *pages_begin; diff --git a/modules/loader/source/elf.cpp b/modules/loader/source/elf.cpp index 229fafb77..d2b295282 100644 --- a/modules/loader/source/elf.cpp +++ b/modules/loader/source/elf.cpp @@ -95,13 +95,13 @@ ElfFile::Section ElfFile::section(size_t index) { CARGO_ASSERT(!bytes.empty(), "Using a null ElfFile instance"); void *start; if (is32Bit()) { - start = reinterpret_cast(bytes.begin() + - field(header32()->section_header_offset) + - index * field(header32()->sht_entry_size)); + start = reinterpret_cast( + bytes.begin() + field(header32()->section_header_offset) + + (index * field(header32()->sht_entry_size))); } else { - start = reinterpret_cast(bytes.begin() + - field(header64()->section_header_offset) + - index * field(header64()->sht_entry_size)); + start = reinterpret_cast( + bytes.begin() + field(header64()->section_header_offset) + + (index * field(header64()->sht_entry_size))); } return Section(this, start); } @@ -129,7 +129,7 @@ loader::SymbolIteratorPair ElfFile::symbols() { ElfFile::Symbol ElfFile::symbol(size_t index) { CARGO_ASSERT(index < symbolCount(), "Symbol index out of bounds"); return Symbol(this, symbol_section->data().begin() + - symbol_section->entrySize() * index); + (symbol_section->entrySize() * index)); } cargo::optional ElfFile::symbol(cargo::string_view name) { diff --git a/modules/metadata/include/metadata/detail/md_value.h b/modules/metadata/include/metadata/detail/md_value.h index 4f4ceb51c..8de3e8444 100644 --- a/modules/metadata/include/metadata/detail/md_value.h +++ b/modules/metadata/include/metadata/detail/md_value.h @@ -96,7 +96,7 @@ class basic_value { /// /// @param rhs The object to compare against. /// @return `true` if data and tag match, `false` otherwise. - inline bool operator==(const basic_value &rhs) const { + bool operator==(const basic_value &rhs) const { return m_type == rhs.m_type && m_data == rhs.m_data; } }; diff --git a/modules/metadata/test/metadata/api.cpp b/modules/metadata/test/metadata/api.cpp index 7a6148f90..802811c10 100644 --- a/modules/metadata/test/metadata/api.cpp +++ b/modules/metadata/test/metadata/api.cpp @@ -347,9 +347,8 @@ TEST_F(MDApiStackTest, md_pushf_md_load_f_SimpleTypes) { TEST_F(MDApiStackTest, md_pushf_md_loadf_ArrayHashTypes) { auto fmt_str = "[u,u,{i:f,f:[u]}]z"; int err = md_pushf(stack, fmt_str, static_cast(1), - static_cast(2), static_cast(-3), - static_cast(2.718), static_cast(3.141), - static_cast(3), "finalize"); + static_cast(2), static_cast(-3), 2.718, + 3.141, static_cast(3), "finalize"); ASSERT_FALSE(MD_CHECK_ERR(err)); EXPECT_EQ(md_top(stack), 1); @@ -433,9 +432,8 @@ TEST_F(MDApiStackTest, md_loadf_InvalidFmtStr) { } TEST_F(MDApiStackTest, md_pushf_UnsuportedCharacters) { - const int err = - md_pushf(stack, "[u, u]f*&^", static_cast(3), - static_cast(5), static_cast(3.141)); + const int err = md_pushf(stack, "[u, u]f*&^", static_cast(3), + static_cast(5), 3.141); ASSERT_TRUE(MD_CHECK_ERR(err)); EXPECT_EQ(err, md_err::MD_E_INVALID_FMT_STR); } diff --git a/modules/metadata/test/metadata/stack_serializer.cpp b/modules/metadata/test/metadata/stack_serializer.cpp index f0d8c46ae..c4e2b83a7 100644 --- a/modules/metadata/test/metadata/stack_serializer.cpp +++ b/modules/metadata/test/metadata/stack_serializer.cpp @@ -139,8 +139,7 @@ TEST_P(MDStackFinalizeFixture, MsgPackTestArrays) { { md_stack_ stack(helper); const int err = md_pushf(static_cast(&stack), fmt_str, - static_cast(3), - static_cast(3.141), "Hello World!!!"); + static_cast(3), 3.141, "Hello World!!!"); ASSERT_FALSE(MD_CHECK_ERR(err)); // serialize diff --git a/modules/mux/source/hal/include/mux/hal/buffer.h b/modules/mux/source/hal/include/mux/hal/buffer.h index 35d7c18dc..9c0999a2d 100644 --- a/modules/mux/source/hal/include/mux/hal/buffer.h +++ b/modules/mux/source/hal/include/mux/hal/buffer.h @@ -37,7 +37,7 @@ struct buffer : mux_buffer_s { static_assert(std::is_base_of_v, "template type Buffer must derive from mux::hal::buffer"); (void)device; - mux_memory_requirements_s memory_requirements = { + const mux_memory_requirements_s memory_requirements = { size, /*alignment*/ 16, mux::hal::memory::HEAP_BUFFER}; auto buffer = allocator.create(memory_requirements); if (!buffer) { @@ -53,7 +53,7 @@ struct buffer : mux_buffer_s { static_assert(std::is_base_of_v, "template type Buffer must derive from mux::hal::buffer"); (void)device; - allocator.destroy(static_cast(buffer)); + allocator.destroy(buffer); } /// @see muxBindBufferMemory diff --git a/modules/mux/source/hal/include/mux/hal/memory.h b/modules/mux/source/hal/include/mux/hal/memory.h index 995f7fc6c..898b351c9 100644 --- a/modules/mux/source/hal/include/mux/hal/memory.h +++ b/modules/mux/source/hal/include/mux/hal/memory.h @@ -61,7 +61,7 @@ struct memory : mux_memory_s { // Align all allocations to at least 128 bytes to match the size of the // largest 16-wide OpenCL-C vector types. const uint32_t align = std::max(alignment, 128u); - ::hal::hal_addr_t target_ptr = device->mem_alloc(size, align); + const ::hal::hal_addr_t target_ptr = device->mem_alloc(size, align); if (::hal::hal_nullptr == target_ptr) { return cargo::make_unexpected(mux_error_out_of_memory); } diff --git a/modules/mux/source/hal/include/mux/hal/query_pool.h b/modules/mux/source/hal/include/mux/hal/query_pool.h index 6c69fe040..b1d3aad95 100644 --- a/modules/mux/source/hal/include/mux/hal/query_pool.h +++ b/modules/mux/source/hal/include/mux/hal/query_pool.h @@ -68,7 +68,7 @@ struct query_pool : mux_query_pool_s { // sizeof(query_pool_s) has no remainder when divided by it. const size_t query_data_offset = sizeof(query_pool) + sizeof(mux_query_duration_result_s) - - sizeof(query_pool) % sizeof(mux_query_duration_result_s); + (sizeof(query_pool) % sizeof(mux_query_duration_result_s)); // Calculate the total size of the allocation. const size_t query_size = sizeof(mux_query_duration_result_s) * query_count; const size_t alloc_size = query_data_offset + query_size; diff --git a/modules/mux/targets/host/extension/example/main.c b/modules/mux/targets/host/extension/example/main.c index f1ce1662c..cf035f22d 100644 --- a/modules/mux/targets/host/extension/example/main.c +++ b/modules/mux/targets/host/extension/example/main.c @@ -73,7 +73,8 @@ cl_platform_id selectPlatform(const char *platform_name_arg) { exit(1); } - cl_platform_id *platforms = malloc(sizeof(cl_platform_id) * num_platforms); + cl_platform_id *platforms = + (cl_platform_id *)malloc(sizeof(cl_platform_id) * num_platforms); if (NULL == platforms) { (void)fprintf(stderr, "\nCould not allocate memory for platform ids\n"); exit(1); @@ -137,7 +138,7 @@ cl_platform_id selectPlatform(const char *platform_name_arg) { } cl_platform_id selected_platform_id = platforms[selected_platform]; - free(platforms); + free((void *)platforms); return selected_platform_id; } @@ -153,7 +154,8 @@ cl_device_id selectDevice(cl_platform_id selected_platform, exit(1); } - cl_device_id *devices = malloc(sizeof(cl_device_id) * num_devices); + cl_device_id *devices = + (cl_device_id *)malloc(sizeof(cl_device_id) * num_devices); if (NULL == devices) { (void)fprintf(stderr, "\nCould not allocate memory for device ids\n"); exit(1); @@ -217,7 +219,7 @@ cl_device_id selectDevice(cl_platform_id selected_platform, } cl_device_id selected_device_id = devices[selected_device]; - free(devices); + free((void *)devices); return selected_device_id; } diff --git a/modules/mux/targets/host/source/command_buffer.cpp b/modules/mux/targets/host/source/command_buffer.cpp index 2dbdf2774..c94f98640 100644 --- a/modules/mux/targets/host/source/command_buffer.cpp +++ b/modules/mux/targets/host/source/command_buffer.cpp @@ -83,7 +83,8 @@ void populatePackedArgs( uint8_t *const buffer_value = static_cast(host_buffer->data) + info.offset; - std::memcpy(packed_args_alloc + offset, &buffer_value, sizeof(void *)); + std::memcpy(packed_args_alloc + offset, + static_cast(&buffer_value), sizeof(void *)); offset += sizeof(void *); } break; case mux_descriptor_info_type_image: { @@ -156,7 +157,8 @@ void populatePackedArgs( } break; case mux_descriptor_info_type_null_buffer: { void *nullvar = nullptr; - std::memcpy(packed_args_alloc + offset, &nullvar, sizeof(void *)); + std::memcpy(packed_args_alloc + offset, static_cast(&nullvar), + sizeof(void *)); offset += sizeof(void *); } break; default: @@ -1020,7 +1022,8 @@ mux_result_t hostUpdateDescriptors(mux_command_buffer_t command_buffer, auto *buffer_value = static_cast(host_buffer->data) + info.offset; - std::memcpy(arg_address, &buffer_value, sizeof(void *)); + std::memcpy(arg_address, static_cast(&buffer_value), + sizeof(void *)); } break; case mux_descriptor_info_type_plain_old_data: { const mux_descriptor_info_plain_old_data_s info = @@ -1036,7 +1039,7 @@ mux_result_t hostUpdateDescriptors(mux_command_buffer_t command_buffer, } break; case mux_descriptor_info_type_null_buffer: { void *null = nullptr; - std::memcpy(arg_address, &null, sizeof(void *)); + std::memcpy(arg_address, static_cast(&null), sizeof(void *)); } break; } } diff --git a/modules/mux/targets/host/source/device.cpp b/modules/mux/targets/host/source/device.cpp index ed0b93af2..acab62631 100644 --- a/modules/mux/targets/host/source/device.cpp +++ b/modules/mux/targets/host/source/device.cpp @@ -59,7 +59,7 @@ #include #endif -uint32_t os_cpu_frequency() { +static uint32_t os_cpu_frequency() { #if defined(__APPLE__) int mib[] = {CTL_HW, HW_CPU_FREQ}; @@ -114,8 +114,8 @@ uint32_t os_cpu_frequency() { if (cargo::string_view(buffer, wanted.size()) == wanted) { uint32_t i = wanted.size(); - while ((i < size) && (':' != buffer[i++])) { - ; + while (i < size) { + if (buffer[i++] == ':') break; } (void)fclose(file); @@ -139,7 +139,7 @@ uint32_t os_cpu_frequency() { /// greater than 4GB, even on 32-bit systems. If you want to report the total /// memory size that will still fit inside a pointer use /// @p os_memory_bounded_size. -uint64_t os_memory_total_size() { +static uint64_t os_memory_total_size() { #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) MEMORYSTATUSEX status; status.dwLength = sizeof(status); @@ -172,7 +172,7 @@ uint64_t os_memory_total_size() { #endif } -uint64_t os_cache_size() { +static uint64_t os_cache_size() { // we query the L1 cache on all platforms, arbitrarily chosen #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) DWORD length = 0; @@ -242,7 +242,7 @@ uint64_t os_cache_size() { #endif } -uint64_t os_cacheline_size() { +static uint64_t os_cacheline_size() { // we query the L1 cacheline on all platforms, arbitrarily chosen #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) DWORD length = 0; @@ -316,7 +316,7 @@ uint64_t os_cacheline_size() { /// /// The function is like @p os_memory_total_size, but it will bound the /// reported memory by what can be addressed by a pointer. -uint64_t os_memory_bounded_size() { +static uint64_t os_memory_bounded_size() { const uint64_t size = os_memory_total_size(); // Limit the memory size to what fits in a size_t, this is necessary when // compiling for 32 bits on a 64 bits host @@ -325,7 +325,7 @@ uint64_t os_memory_bounded_size() { : std::numeric_limits::max(); } -uint32_t os_num_cpus() { +static uint32_t os_num_cpus() { #if defined(__linux__) || defined(__APPLE__) return static_cast(std::max(1L, sysconf(_SC_NPROCESSORS_ONLN))); #elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) @@ -438,7 +438,7 @@ device_info_s::device_info_s(host::arch arch, host::os os, bool native, // TODO Reported memory size is quartered (rounded up) in order to pass the // OpenCL CTS however this probably should be an OCL specific fix and not in // the host target. - this->memory_size = native ? (os_memory_bounded_size() - 1) / 4 + 1 : 0; + this->memory_size = native ? ((os_memory_bounded_size() - 1) / 4) + 1 : 0; // All memory could be allocated at once. this->allocation_size = this->memory_size; this->cache_size = native ? os_cache_size() : 0; diff --git a/modules/mux/targets/host/source/metadata_hooks.cpp b/modules/mux/targets/host/source/metadata_hooks.cpp index 8b9f51018..fca30c959 100644 --- a/modules/mux/targets/host/source/metadata_hooks.cpp +++ b/modules/mux/targets/host/source/metadata_hooks.cpp @@ -49,7 +49,7 @@ md_hooks getHostMdReadHooks() { md_hooks.deallocate = [](void *ptr, void *userdata) { auto *elfUserdata = static_cast(userdata); - return elfUserdata->allocator->free(ptr); + elfUserdata->allocator->free(ptr); }; return md_hooks; } diff --git a/modules/mux/targets/host/source/query_pool.cpp b/modules/mux/targets/host/source/query_pool.cpp index f9118c98b..edbf34eca 100644 --- a/modules/mux/targets/host/source/query_pool.cpp +++ b/modules/mux/targets/host/source/query_pool.cpp @@ -168,7 +168,7 @@ void host::query_pool_s::reset() { void host::query_pool_s::reset(size_t offset, size_t count) { if (type == mux_query_type_duration) { std::memset(static_cast(this->data) + - offset * sizeof(mux_query_duration_result_s), + (offset * sizeof(mux_query_duration_result_s)), 0, count * sizeof(mux_query_duration_result_s)); } #ifdef CA_HOST_ENABLE_PAPI_COUNTERS diff --git a/modules/mux/targets/riscv/include/riscv/queue.h b/modules/mux/targets/riscv/include/riscv/queue.h index 04fee4c90..6cdeac258 100644 --- a/modules/mux/targets/riscv/include/riscv/queue.h +++ b/modules/mux/targets/riscv/include/riscv/queue.h @@ -61,7 +61,7 @@ struct queue_s final : public mux_queue_s { queue_s(mux::allocator allocator, mux_device_t device) : pending{allocator}, running{false}, terminate{false} { this->device = device; - cargo::lock_guard lock(mutex); + const cargo::lock_guard lock(mutex); thread = cargo::thread{[this]() { run(); }}; thread.set_name("riscv:queue"); } @@ -69,7 +69,7 @@ struct queue_s final : public mux_queue_s { /// @brief Destructor. ~queue_s() { { - cargo::lock_guard lock(mutex); + const cargo::lock_guard lock(mutex); terminate = true; condition_variable.notify_all(); } diff --git a/modules/mux/targets/riscv/source/command_buffer.cpp b/modules/mux/targets/riscv/source/command_buffer.cpp index 20a4f232c..37cb62f59 100644 --- a/modules/mux/targets/riscv/source/command_buffer.cpp +++ b/modules/mux/targets/riscv/source/command_buffer.cpp @@ -62,7 +62,7 @@ void command_ndrange_s::operator()(riscv::queue_s *queue, bool &error) { error = true; return; } - hal::hal_program_t program = hal_device->program_load( + const hal::hal_program_t program = hal_device->program_load( kernel->object_code.data(), kernel->object_code.size()); if (program == hal::hal_invalid_program) { error = true; @@ -89,7 +89,7 @@ void command_ndrange_s::operator()(riscv::queue_s *queue, bool &error) { {global_size[0], global_size[1], global_size[2]}, {local_size[0], local_size[1], local_size[2]}}; // execute the kernel - bool success = + const bool success = hal_device->kernel_exec(program, hal_kernel, &hal_ndrange, kernel_args, num_kernel_args, dimensions); hal_device->program_free(program); @@ -253,7 +253,7 @@ mux_result_t riscvCommandReadBuffer(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.emplace_back( riscv::command_read_buffer_s{static_cast(buffer), @@ -283,7 +283,7 @@ mux_result_t riscvCommandReadBufferRegions(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); char *data = reinterpret_cast(riscv_pointer); @@ -360,7 +360,7 @@ mux_result_t riscvCommandWriteBuffer( auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.emplace_back( riscv::command_write_buffer_s{static_cast(buffer), @@ -389,7 +389,7 @@ mux_result_t riscvCommandWriteBufferRegions(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); const char *data = reinterpret_cast(riscv_pointer); @@ -462,7 +462,7 @@ mux_result_t riscvCommandCopyBuffer(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); // lastly copy the new command onto the end of the buffer if (riscv->commands.emplace_back(riscv::command_copy_buffer_s{ @@ -493,7 +493,7 @@ mux_result_t riscvCommandCopyBufferRegions(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.reserve(riscv->commands.size() + regions_length)) { return mux_error_out_of_memory; @@ -564,7 +564,7 @@ mux_result_t riscvCommandFillBuffer(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); riscv::command_fill_buffer_s fill_buffer; fill_buffer.buffer = static_cast(buffer); @@ -746,7 +746,7 @@ void setHALArgs(mux::dynamic_array &pod_data, const auto &descriptor = descriptors[i]; switch (descriptor.type) { case mux_descriptor_info_type_buffer: { - mux_descriptor_info_buffer_s info = descriptor.buffer_descriptor; + const mux_descriptor_info_buffer_s info = descriptor.buffer_descriptor; riscv::buffer_s *const riscv_buffer = static_cast(info.buffer); hal::hal_arg_t arg; @@ -758,7 +758,7 @@ void setHALArgs(mux::dynamic_array &pod_data, kernel_args[i] = arg; } break; case mux_descriptor_info_type_plain_old_data: { - mux_descriptor_info_plain_old_data_s info = + const mux_descriptor_info_plain_old_data_s info = descriptor.plain_old_data_descriptor; hal::hal_arg_t arg; arg.kind = hal::hal_arg_value; @@ -771,7 +771,7 @@ void setHALArgs(mux::dynamic_array &pod_data, } break; case mux_descriptor_info_type_shared_local_buffer: { - mux_descriptor_info_shared_local_buffer_s info = + const mux_descriptor_info_shared_local_buffer_s info = descriptor.shared_local_buffer_descriptor; hal::hal_arg_t arg; arg.kind = hal::hal_arg_address; @@ -787,6 +787,8 @@ void setHALArgs(mux::dynamic_array &pod_data, arg.size = 0; kernel_args[i] = arg; } break; + default: + break; } } } @@ -798,13 +800,13 @@ mux_result_t riscvCommandNDRange(mux_command_buffer_t command_buffer, const mux_sync_point_t *, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); auto *riscv_device = static_cast(riscv->device); auto *hal_device = riscv_device->hal_device; const hal::hal_device_info_t *hal_device_info = hal_device->get_info(); - mux::allocator allocator(riscv->allocator_info); + const mux::allocator allocator(riscv->allocator_info); mux::dynamic_array descriptors{allocator}; if (descriptors.alloc(options.descriptors_length)) { return mux_error_out_of_memory; @@ -880,7 +882,7 @@ mux_result_t riscvUpdateDescriptors(mux_command_buffer_t command_buffer, // Get the command to update. auto *riscv_command_buffer = static_cast(command_buffer); - cargo::lock_guard lock{riscv_command_buffer->mutex}; + const cargo::lock_guard lock{riscv_command_buffer->mutex}; auto &nd_range_to_update = riscv_command_buffer->commands[command_id]; // Check the command being updated is actually an ND range. @@ -899,18 +901,19 @@ mux_result_t riscvUpdateDescriptors(mux_command_buffer_t command_buffer, default: return mux_error_invalid_value; case mux_descriptor_info_type_buffer: { - mux_descriptor_info_buffer_s info = descriptors[i].buffer_descriptor; + const mux_descriptor_info_buffer_s info = + descriptors[i].buffer_descriptor; auto *const riscv_buffer = static_cast(info.buffer); arg.address = riscv_buffer->targetPtr + info.offset; } break; case mux_descriptor_info_type_plain_old_data: { - mux_descriptor_info_plain_old_data_s info = + const mux_descriptor_info_plain_old_data_s info = descriptors[i].plain_old_data_descriptor; std::memcpy(arg.pod_data, info.data, arg.size); } break; case mux_descriptor_info_type_shared_local_buffer: { - mux_descriptor_info_shared_local_buffer_s info = + const mux_descriptor_info_shared_local_buffer_s info = descriptors[i].shared_local_buffer_descriptor; arg.size = info.size; } break; @@ -931,7 +934,7 @@ mux_result_t riscvCommandUserCallback(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.emplace_back( riscv::command_user_callback_s{user_function, user_data})) { @@ -958,7 +961,7 @@ mux_result_t riscvCommandBeginQuery(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.emplace_back(riscv::command_begin_query_s{ static_cast(query_pool), query_index, @@ -986,7 +989,7 @@ mux_result_t riscvCommandEndQuery(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); auto found = std::find_if(riscv->commands.begin(), riscv->commands.end(), @@ -1027,7 +1030,7 @@ mux_result_t riscvCommandResetQueryPool(mux_command_buffer_t command_buffer, mux_sync_point_t *sync_point) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (riscv->commands.emplace_back(riscv::command_reset_query_pool_s{ static_cast(query_pool), query_index, @@ -1051,7 +1054,7 @@ mux_result_t riscvCommandResetQueryPool(mux_command_buffer_t command_buffer, mux_result_t riscvResetCommandBuffer(mux_command_buffer_t command_buffer) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); riscv->commands.clear(); @@ -1060,7 +1063,7 @@ mux_result_t riscvResetCommandBuffer(mux_command_buffer_t command_buffer) { mux_result_t riscvFinalizeCommandBuffer(mux_command_buffer_t command_buffer) { auto riscv = static_cast(command_buffer); - cargo::lock_guard lock(riscv->mutex); + const cargo::lock_guard lock(riscv->mutex); if (nullptr == command_buffer) { return mux_error_null_out_parameter; } @@ -1075,7 +1078,7 @@ mux_result_t cloneNDRangeCommand(mux_allocator_info_t allocator_info, const riscv::command_ndrange_s &original, riscv::command_buffer_s *cloned_command_buffer) CARGO_TS_REQUIRES(cloned_command_buffer->mutex) { - mux::allocator allocator(allocator_info); + const mux::allocator allocator(allocator_info); mux::dynamic_array descriptors{allocator}; if (descriptors.alloc(original.num_kernel_args)) { return mux_error_out_of_memory; @@ -1148,8 +1151,10 @@ mux_result_t riscvCloneCommandBuffer(mux_device_t device, // MuxUpdateDescriptors() without affecting the original command-buffer. auto *riscv_command_buffer = static_cast(command_buffer); - cargo::lock_guard lock_original{riscv_command_buffer->mutex}; - cargo::lock_guard lock_clone{cloned_command_buffer->mutex}; + const cargo::lock_guard lock_original{ + riscv_command_buffer->mutex}; + const cargo::lock_guard lock_clone{ + cloned_command_buffer->mutex}; for (auto &command : riscv_command_buffer->commands) { if (command.type != riscv::command_type_ndrange) { @@ -1176,7 +1181,7 @@ void riscvDestroyCommandBuffer(mux_device_t device, auto *riscv_command_buffer = static_cast(command_buffer); { - cargo::lock_guard lock{riscv_command_buffer->mutex}; + const cargo::lock_guard lock{riscv_command_buffer->mutex}; for (auto sync_point : riscv_command_buffer->sync_points) { allocator.destroy(sync_point); } diff --git a/modules/mux/targets/riscv/source/device_info.cpp b/modules/mux/targets/riscv/source/device_info.cpp index 375e0a42e..65ed38ce6 100644 --- a/modules/mux/targets/riscv/source/device_info.cpp +++ b/modules/mux/targets/riscv/source/device_info.cpp @@ -110,12 +110,12 @@ device_info_s::device_info_s() this->compute_units = 1; this->buffer_alignment = sizeof(uint64_t) * 16; this->memory_size = - 10 * 1024 * 1024; // default value - should be updated using hal values + 10L * 1024 * 1024; // default value - should be updated using hal values // All memory could be allocated at once. this->allocation_size = this->memory_size; this->cache_size = 0; this->cacheline_size = 0; - this->shared_local_memory_size = 32 * 1024; + this->shared_local_memory_size = 32L * 1024; // default to 128 bit (16 bytes) this->native_vector_width = 128 / (8 * sizeof(uint8_t)); @@ -164,9 +164,10 @@ device_info_s::device_info_s() this->num_sub_group_sizes = sg_sizes.size(); } -mux_result_t GetDeviceInfos(uint32_t device_types, uint64_t device_infos_length, - mux_device_info_t *out_device_infos, - uint64_t *out_device_infos_length) { +static mux_result_t GetDeviceInfos(uint32_t device_types, + uint64_t device_infos_length, + mux_device_info_t *out_device_infos, + uint64_t *out_device_infos_length) { // ensure our device infos have been enumerated if (!riscv::enumerate_device_infos()) { return mux_error_failure; diff --git a/modules/mux/targets/riscv/source/executable.cpp b/modules/mux/targets/riscv/source/executable.cpp index 9508d56eb..9eced0329 100644 --- a/modules/mux/targets/riscv/source/executable.cpp +++ b/modules/mux/targets/riscv/source/executable.cpp @@ -53,7 +53,7 @@ md_hooks getElfMetadataReadHooks() { md_hooks.deallocate = [](void *ptr, void *userdata) { auto *elfUserdata = static_cast(userdata); - return elfUserdata->allocator->free(ptr); + elfUserdata->allocator->free(ptr); }; return md_hooks; diff --git a/modules/mux/targets/riscv/source/fence.cpp b/modules/mux/targets/riscv/source/fence.cpp index 9d4f61e07..5a861b45b 100644 --- a/modules/mux/targets/riscv/source/fence.cpp +++ b/modules/mux/targets/riscv/source/fence.cpp @@ -21,7 +21,7 @@ mux_result_t riscvCreateFence(mux_device_t device, mux_allocator_info_t allocator_info, mux_fence_t *out_fence) { - mux::allocator allocator(allocator_info); + const mux::allocator allocator(allocator_info); auto fence = riscv::fence_s::create(device, allocator); if (!fence) { return mux_error_out_of_memory; diff --git a/modules/mux/targets/riscv/source/hal.cpp b/modules/mux/targets/riscv/source/hal.cpp index 897135711..3e4293e66 100644 --- a/modules/mux/targets/riscv/source/hal.cpp +++ b/modules/mux/targets/riscv/source/hal.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include +#include namespace riscv { diff --git a/modules/mux/targets/riscv/source/kernel.cpp b/modules/mux/targets/riscv/source/kernel.cpp index ec43c4971..d0583681b 100644 --- a/modules/mux/targets/riscv/source/kernel.cpp +++ b/modules/mux/targets/riscv/source/kernel.cpp @@ -159,7 +159,7 @@ mux_result_t kernel_s::getLocalSizeForSubGroupCount(size_t sub_group_count, // work-group size we've reported, we'd receive a kernel variant with the // same sub-group size as we've assumed for the calculations. mux::hal::kernel_variant_s variant; - mux_result_t res = getKernelVariantForWGSize( + const mux_result_t res = getKernelVariantForWGSize( *out_local_size_x, *out_local_size_y, *out_local_size_z, &variant); if (res != mux_success || variant.sub_group_size != max_sub_group_size) { return mux_error_internal; diff --git a/modules/mux/targets/riscv/source/queue.cpp b/modules/mux/targets/riscv/source/queue.cpp index f60b95aae..1254f7490 100644 --- a/modules/mux/targets/riscv/source/queue.cpp +++ b/modules/mux/targets/riscv/source/queue.cpp @@ -77,8 +77,9 @@ bool dispatch_s::is_terminated() const { void (*user_function)(mux_command_buffer_t command_buffer, mux_result_t error, void *const user_data), void *user_data) { - cargo::lock_guard command_buffer_lock{command_buffer->mutex}; - cargo::lock_guard queue_lock{mutex}; + const cargo::lock_guard command_buffer_lock{ + command_buffer->mutex}; + const cargo::lock_guard queue_lock{mutex}; // Reset optional fence state. if (fence) { fence->reset(); @@ -140,7 +141,8 @@ void queue_s::run() { mux_result_t result = mux_error_failure; { - cargo::lock_guard lock{dispatch->command_buffer->mutex}; + const cargo::lock_guard lock{ + dispatch->command_buffer->mutex}; // Execute the commands in the command buffer. if (!dispatch->is_terminated()) { result = dispatch->command_buffer->execute(this); @@ -153,9 +155,9 @@ void queue_s::run() { dispatch->notify_user(result); { - cargo::lock_guard command_buffer_lock{ + const cargo::lock_guard command_buffer_lock{ dispatch->command_buffer->mutex}; - cargo::lock_guard queue_lock{mutex}; + const cargo::lock_guard queue_lock{mutex}; if (result) { // There was an error, propogate termination flags. dispatch->terminate(); @@ -176,7 +178,7 @@ void queue_s::run() { // 5) The queue thread is resumed by the OS and tries to unlock the command // buffer mutex. The mutex has already been deleted, resulting in a crash. { - cargo::lock_guard queue_lock{mutex}; + const cargo::lock_guard queue_lock{mutex}; running = false; condition_variable.notify_all(); } diff --git a/modules/mux/targets/riscv/source/semaphore.cpp b/modules/mux/targets/riscv/source/semaphore.cpp index fe14b57e4..51d9d0d26 100644 --- a/modules/mux/targets/riscv/source/semaphore.cpp +++ b/modules/mux/targets/riscv/source/semaphore.cpp @@ -21,7 +21,7 @@ mux_result_t riscvCreateSemaphore(mux_device_t device, mux_allocator_info_t allocator_info, mux_semaphore_t *out_semaphore) { - mux::allocator allocator(allocator_info); + const mux::allocator allocator(allocator_info); auto semaphore = riscv::semaphore_s::create(device, allocator); if (!semaphore) { @@ -33,7 +33,7 @@ mux_result_t riscvCreateSemaphore(mux_device_t device, void riscvDestroySemaphore(mux_device_t device, mux_semaphore_t semaphore, mux_allocator_info_t allocator_info) { - mux::allocator allocator(allocator_info); + const mux::allocator allocator(allocator_info); riscv::semaphore_s::destroy( device, static_cast(semaphore), allocator); } diff --git a/modules/mux/test/muxCloneCommandBuffer.cpp b/modules/mux/test/muxCloneCommandBuffer.cpp index 74a1772c7..3857bd8f4 100644 --- a/modules/mux/test/muxCloneCommandBuffer.cpp +++ b/modules/mux/test/muxCloneCommandBuffer.cpp @@ -192,7 +192,7 @@ struct muxCloneCommandBufferSingleBufferTest /// @brief The buffer object. mux_buffer_t buffer = nullptr; /// @brief The size of the buffer in bytes. - constexpr static size_t buffer_size_in_bytes = 256; + static constexpr size_t buffer_size_in_bytes = 256; /// @brief A block of host memory that can be read from or written to. char data[buffer_size_in_bytes]; @@ -338,7 +338,7 @@ struct muxCloneCommandBufferTwoBufferTest : public muxCloneCommandBufferTest { /// @brief The second buffer object. mux_buffer_t buffer_two = nullptr; /// @brief The size of the buffer in bytes. - constexpr static size_t buffer_size_in_bytes = 256; + static constexpr size_t buffer_size_in_bytes = 256; /// @brief Virtual method used to setup any resources for the test fixture /// that can't be done in the constructor. @@ -477,9 +477,9 @@ struct muxCloneCommandBufferQueryTest : muxCloneCommandBufferTest { /// @brief Query pool used by the query. mux_query_pool_t query_pool = nullptr; /// @brief Number of queries to allocate storage for. - constexpr static uint32_t query_count = 1; + static constexpr uint32_t query_count = 1; /// @brief Query slot index that will contain the result. - constexpr static uint32_t query_index = 0; + static constexpr uint32_t query_index = 0; /// @brief Virtual method used to setup any resources for the test fixture /// that can't be done in the constructor. @@ -572,9 +572,9 @@ TEST_P(muxCloneCommandBufferTest, CloneUserCallbackThenCheckCommandBuffer) { }; // Enqueue the original command buffer. - ASSERT_SUCCESS(muxCommandUserCallback(command_buffer_to_clone, user_callback, - &command_buffer_executed, 0, nullptr, - nullptr)); + ASSERT_SUCCESS(muxCommandUserCallback( + command_buffer_to_clone, user_callback, + static_cast(&command_buffer_executed), 0, nullptr, nullptr)); ASSERT_SUCCESS(muxFinalizeCommandBuffer(command_buffer_to_clone)); ASSERT_SUCCESS(muxDispatch(queue, command_buffer_to_clone, nullptr, nullptr, 0, nullptr, 0, nullptr, nullptr)); @@ -672,9 +672,9 @@ TEST_P(muxCloneCommandBufferTest, CloneUserCallbackInLoopBlocking) { }; // Enqueue the original command buffer. - ASSERT_SUCCESS(muxCommandUserCallback(command_buffer_to_clone, user_callback, - &command_buffer_executed, 0, nullptr, - nullptr)); + ASSERT_SUCCESS(muxCommandUserCallback( + command_buffer_to_clone, user_callback, + static_cast(&command_buffer_executed), 0, nullptr, nullptr)); ASSERT_SUCCESS(muxFinalizeCommandBuffer(command_buffer_to_clone)); ASSERT_SUCCESS(muxDispatch(queue, command_buffer_to_clone, nullptr, nullptr, 0, nullptr, 0, nullptr, nullptr)); diff --git a/modules/mux/test/muxUpdateDescriptors.cpp b/modules/mux/test/muxUpdateDescriptors.cpp index fd4ba0541..7512d208f 100644 --- a/modules/mux/test/muxUpdateDescriptors.cpp +++ b/modules/mux/test/muxUpdateDescriptors.cpp @@ -80,11 +80,11 @@ struct muxUpdateDescriptorsTest : public DeviceCompilerTest { /// @brief Address type of the devices ISA. mux_address_type_e address_type; /// @brief The local (x, y, z) dimensions of the nd range we will enqueue. - constexpr static size_t local_size[] = {1, 1, 1}; + static constexpr size_t local_size[] = {1, 1, 1}; /// @brief The global offsets of the nd range we will enqueue. - constexpr static size_t global_offset[] = {0, 0, 0}; + static constexpr size_t global_offset[] = {0, 0, 0}; /// @brief The global dimensions of the nd range we will enqueue. - constexpr static size_t global_size[] = {256, 1, 1}; + static constexpr size_t global_size[] = {256, 1, 1}; /// @brief Descriptors for arguments to kernel. std::vector descriptors; /// @brief The nd range options for enqueing a kernel. @@ -166,15 +166,15 @@ struct muxUpdateDescriptorsBufferTest : public muxUpdateDescriptorsTest { /// @brief Updated output data. std::vector data_out_updated; /// @brief Memory size in bytes of input and output buffers. - constexpr static size_t buffer_size = global_size[0] * sizeof(int32_t); + static constexpr size_t buffer_size = global_size[0] * sizeof(int32_t); /// @brief The initial value that will fill the input buffer. - constexpr static char input_value = 0x42; + static constexpr char input_value = 0x42; /// @brief Constructor. muxUpdateDescriptorsBufferTest() : data_in(buffer_size, input_value), data_out(buffer_size, 0x00), - data_out_updated(buffer_size, 0x00){}; + data_out_updated(buffer_size, 0x00) {}; /// @brief Virtual method used to setup any resources for the test fixture /// that can't be done in the constructor. @@ -495,14 +495,14 @@ struct muxUpdateDescriptorsPODTest : public muxUpdateDescriptorsTest { /// @brief Initial output data. std::vector data_out; /// @brief Memory size in bytes of input and output buffers. - constexpr static size_t buffer_size = global_size[0] * sizeof(int32_t); + static constexpr size_t buffer_size = global_size[0] * sizeof(int32_t); /// @brief The initial value that will be broadcast to the output buffer. - constexpr static int32_t input_value = 0x42; + static constexpr int32_t input_value = 0x42; /// @brief The updated value that will be broadcast to the output buffer. - constexpr static int32_t input_value_updated = 0x99; + static constexpr int32_t input_value_updated = 0x99; /// @brief Constructor. - muxUpdateDescriptorsPODTest() : data_out(buffer_size, 0x00){}; + muxUpdateDescriptorsPODTest() : data_out(buffer_size, 0x00) {}; /// @brief Virtual method used to setup any resources for the test fixture /// that can't be done in the constructor. diff --git a/modules/mux/utils/include/mux/utils/allocator.h b/modules/mux/utils/include/mux/utils/allocator.h index b11a98db0..9df3dd726 100644 --- a/modules/mux/utils/include/mux/utils/allocator.h +++ b/modules/mux/utils/include/mux/utils/allocator.h @@ -180,7 +180,7 @@ class cargo_allocator { /// /// @param pointer Pointer to allocated memory. void free(value_type *pointer) { - Allocator.free(Allocator.user_data, pointer); + Allocator.free(Allocator.user_data, static_cast(pointer)); } /// @brief Allocate and construct an object. @@ -192,8 +192,8 @@ class cargo_allocator { /// otherwise. template value_type *create(Args &&...args) { - value_type *object = static_cast(alloc(1)); - new (object) value_type(std::forward(args)...); + value_type *object = alloc(1); + new (static_cast(object)) value_type(std::forward(args)...); return object; } diff --git a/modules/mux/utils/source/helpers.cpp b/modules/mux/utils/source/helpers.cpp index 31a557faa..ea85aace4 100644 --- a/modules/mux/utils/source/helpers.cpp +++ b/modules/mux/utils/source/helpers.cpp @@ -19,6 +19,8 @@ #include #include +#include + uint32_t mux::findFirstSupportedHeap(uint32_t heaps) { // https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup static const uint32_t lookupTable[32] = { @@ -62,9 +64,7 @@ void *mux::alloc(void *, size_t size, size_t alignment) { void *pointer = 0; // our minimum alignment is the pointer width - if (alignment < sizeof(void *)) { - alignment = sizeof(void *); - } + alignment = std::max(alignment, sizeof(void *)); size_t v = alignment; diff --git a/modules/tracer/include/tracer/tracer.h b/modules/tracer/include/tracer/tracer.h index ab9edc73e..672372e6e 100644 --- a/modules/tracer/include/tracer/tracer.h +++ b/modules/tracer/include/tracer/tracer.h @@ -70,7 +70,7 @@ uint64_t getCurrentTimestamp(); /// @brief Benchmark base class for the Bench object. template struct BenchmarkCategory { - constexpr static bool enabled = enable; + static constexpr bool enabled = enable; }; template diff --git a/modules/utils/source/system.cpp b/modules/utils/source/system.cpp index 867113d36..ebbcff6f1 100644 --- a/modules/utils/source/system.cpp +++ b/modules/utils/source/system.cpp @@ -41,17 +41,23 @@ uint64_t timestampNanoSeconds() { // without problems. #if defined(CA_PLATFORM_LINUX) || defined(CA_PLATFORM_ANDROID) timespec ts; - ::clock_gettime(CLOCK_REALTIME, &ts); - tickCount = static_cast(ts.tv_sec) * 1000000000 + - static_cast(ts.tv_nsec); + if (::clock_gettime(CLOCK_REALTIME, &ts) == 0) { + tickCount = static_cast(ts.tv_sec) * 1000000000 + + static_cast(ts.tv_nsec); + } #elif defined(CA_PLATFORM_MAC) + kern_result_t res; clock_serv_t cclock; mach_timespec_t mts; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - tickCount = static_cast(mts.tv_sec) * 1000000000 + - static_cast(mts.tv_nsec); + res = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + if (res == KERN_SUCCESS) { + res = clock_get_time(cclock, &mts); + if (res == KERN_SUCCESS) { + tickCount = static_cast(mts.tv_sec) * 1000000000 + + static_cast(mts.tv_nsec); + } + mach_port_deallocate(mach_task_self(), cclock); + } #elif defined(CA_PLATFORM_WINDOWS) LARGE_INTEGER counter; LARGE_INTEGER frequency; diff --git a/platform/arm-emcos/emcos_device_info.h.in b/platform/arm-emcos/emcos_device_info.h.in index 4ef34476d..eeb68b47c 100644 --- a/platform/arm-emcos/emcos_device_info.h.in +++ b/platform/arm-emcos/emcos_device_info.h.in @@ -21,13 +21,9 @@ namespace emcos { -inline uint32_t get_num_cpus() { - return MP_CONTROL_CORE_COUNT; -} +inline uint32_t get_num_cpus() { return MP_CONTROL_CORE_COUNT; } -inline uint64_t get_device_total_memory_size() { - return @EMCOS_TOTAL_MEMORY_SIZE@; -} +inline uint64_t get_device_total_memory_size() { return @EMCOS_TOTAL_MEMORY_SIZE@; } inline size_t get_device_page_size() { return @EMCOS_PAGE_SIZE@; } diff --git a/source/cl/examples/CommandBufferKHR/source/main.cpp b/source/cl/examples/CommandBufferKHR/source/main.cpp index d03e4ed9b..3df07b5df 100644 --- a/source/cl/examples/CommandBufferKHR/source/main.cpp +++ b/source/cl/examples/CommandBufferKHR/source/main.cpp @@ -117,9 +117,12 @@ int main(const int argc, const char **argv) { clCreateBuffer(context, CL_MEM_WRITE_ONLY, tile_size, nullptr, &error); CL_CHECK(error); - CL_CHECK(clSetKernelArg(kernel, 0, sizeof(buffer_tile1), &buffer_tile1)); - CL_CHECK(clSetKernelArg(kernel, 1, sizeof(buffer_tile2), &buffer_tile2)); - CL_CHECK(clSetKernelArg(kernel, 2, sizeof(buffer_res), &buffer_res)); + CL_CHECK(clSetKernelArg(kernel, 0, sizeof(buffer_tile1), + static_cast(&buffer_tile1))); + CL_CHECK(clSetKernelArg(kernel, 1, sizeof(buffer_tile2), + static_cast(&buffer_tile2))); + CL_CHECK(clSetKernelArg(kernel, 2, sizeof(buffer_res), + static_cast(&buffer_res))); // CA doesn't support OOO queues. cl_command_queue command_queue = diff --git a/source/cl/examples/MutableDispatchKHR/source/main.cpp b/source/cl/examples/MutableDispatchKHR/source/main.cpp index 1f6783c6d..0ff97f3ad 100644 --- a/source/cl/examples/MutableDispatchKHR/source/main.cpp +++ b/source/cl/examples/MutableDispatchKHR/source/main.cpp @@ -150,9 +150,12 @@ int main(const int argc, const char **argv) { clCreateCommandBufferKHR(1, &command_queue, properties, &error); CL_CHECK(error); - CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_A_buffers[0])); - CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), &input_B_buffers[0])); - CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), &output_buffers[0])); + CL_CHECK(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_A_buffers[0]))); + CL_CHECK(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&input_B_buffers[0]))); + CL_CHECK(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&output_buffers[0]))); // Instruct the nd-range command to allow for mutable kernel arguments cl_ndrange_kernel_command_properties_khr mutable_properties[] = { @@ -209,12 +212,12 @@ int main(const int argc, const char **argv) { // If not executing the first frame if (i != 0) { // Configure the mutable configuration to update the kernel arguments - const cl_mutable_dispatch_arg_khr arg_0{0, sizeof(cl_mem), - &input_A_buffer}; - const cl_mutable_dispatch_arg_khr arg_1{1, sizeof(cl_mem), - &input_B_buffer}; - const cl_mutable_dispatch_arg_khr arg_2{2, sizeof(cl_mem), - &output_buffer}; + const cl_mutable_dispatch_arg_khr arg_0{ + 0, sizeof(cl_mem), static_cast(&input_A_buffer)}; + const cl_mutable_dispatch_arg_khr arg_1{ + 1, sizeof(cl_mem), static_cast(&input_B_buffer)}; + const cl_mutable_dispatch_arg_khr arg_2{ + 2, sizeof(cl_mem), static_cast(&output_buffer)}; const cl_mutable_dispatch_arg_khr args[] = {arg_0, arg_1, arg_2}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, diff --git a/source/cl/examples/SubGroups/source/main.cpp b/source/cl/examples/SubGroups/source/main.cpp index fc28f4010..1267cdd75 100644 --- a/source/cl/examples/SubGroups/source/main.cpp +++ b/source/cl/examples/SubGroups/source/main.cpp @@ -166,9 +166,11 @@ kernel void reduction(global int *in, local int *tmp, global int *out) { input_buffer_size, input_data.data(), 0, nullptr, nullptr)); - CL_CHECK(clSetKernelArg(kernel, 0, sizeof(input_buffer), &input_buffer)); + CL_CHECK(clSetKernelArg(kernel, 0, sizeof(input_buffer), + static_cast(&input_buffer))); CL_CHECK(clSetKernelArg(kernel, 1, local_buffer_size, nullptr)); - CL_CHECK(clSetKernelArg(kernel, 2, sizeof(output_buffer), &output_buffer)); + CL_CHECK(clSetKernelArg(kernel, 2, sizeof(output_buffer), + static_cast(&output_buffer))); CL_CHECK(clEnqueueNDRangeKernel(command_queue, kernel, 1, nullptr, &global_size, &local_size, 0, nullptr, diff --git a/source/cl/examples/VectorAddition/source/main.c b/source/cl/examples/VectorAddition/source/main.c index 58361695e..a29cea685 100644 --- a/source/cl/examples/VectorAddition/source/main.c +++ b/source/cl/examples/VectorAddition/source/main.c @@ -66,9 +66,12 @@ int main(const int argc, const char **argv) { /* Create kernel and set arguments */ cl_kernel kernel = clCreateKernel(program, "vector_addition", &errcode); IS_CL_SUCCESS(errcode); - IS_CL_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src1_buffer), &src1_buffer)); - IS_CL_SUCCESS(clSetKernelArg(kernel, 1, sizeof(src2_buffer), &src2_buffer)); - IS_CL_SUCCESS(clSetKernelArg(kernel, 2, sizeof(dst_buffer), &dst_buffer)); + IS_CL_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(src1_buffer), (void *)&src1_buffer)); + IS_CL_SUCCESS( + clSetKernelArg(kernel, 1, sizeof(src2_buffer), (void *)&src2_buffer)); + IS_CL_SUCCESS( + clSetKernelArg(kernel, 2, sizeof(dst_buffer), (void *)&dst_buffer)); printf(" * Created kernel and set arguments\n"); /* Create command queue */ diff --git a/source/cl/examples/include/common.h b/source/cl/examples/include/common.h index 1dc850889..c8402b2c7 100644 --- a/source/cl/examples/include/common.h +++ b/source/cl/examples/include/common.h @@ -166,7 +166,7 @@ cl_platform_id selectPlatform(const char *platform_name_arg) { } cl_platform_id selected_platform_id = platforms[selected_platform]; - free(platforms); + free((void *)platforms); return selected_platform_id; } @@ -268,7 +268,7 @@ cl_device_id selectDevice(cl_platform_id selected_platform, exit(0); } - free(devices); + free((void *)devices); return selected_device_id; } #endif // CL_COMMON_EXAMPLES_H_INCLUDED diff --git a/source/cl/include/cl/base.h b/source/cl/include/cl/base.h index 4934a56a5..a19190185 100644 --- a/source/cl/include/cl/base.h +++ b/source/cl/include/cl/base.h @@ -68,6 +68,8 @@ cl_int invalid(); /// zero. template class base { + friend T; + /// @brief Pointer to the ICD dispatch table. /// /// This **must** be the **first** field of the object the ICD loader @@ -80,7 +82,6 @@ class base { /// @brief Pointer type of the inheriting object. using object_type = T *; - public: /// @brief Construct and initialize internal or external reference count. /// /// An object created via the OpenCL API must start with an external @@ -110,6 +111,7 @@ class base { /// Also deletes the copy constructor and the assignment operators. base(base &&) = delete; + public: /// @brief Increment the external reference count. /// /// @note This should only be invoked by `::cl::retainExternal`. diff --git a/source/cl/include/cl/semaphore.h b/source/cl/include/cl/semaphore.h index 745cf35f3..85581784b 100644 --- a/source/cl/include/cl/semaphore.h +++ b/source/cl/include/cl/semaphore.h @@ -35,7 +35,7 @@ struct _mux_shared_semaphore final { cl_device_id device; _mux_shared_semaphore(cl_device_id device, mux_semaphore_t semaphore) - : device(device), ref_count(1), semaphore(semaphore){}; + : device(device), ref_count(1), semaphore(semaphore) {}; cl_uint ref_count; public: diff --git a/source/cl/source/command_queue.cpp b/source/cl/source/command_queue.cpp index 84011d74c..23a7587a0 100644 --- a/source/cl/source/command_queue.cpp +++ b/source/cl/source/command_queue.cpp @@ -199,7 +199,7 @@ cl_int _cl_command_queue::flush() { // Use a raii_wrapper to ensure in_flush is set to false on exit struct raii_wrapper { - raii_wrapper(bool &in_flush) : in_flush(in_flush){}; + raii_wrapper(bool &in_flush) : in_flush(in_flush) {}; ~raii_wrapper() { in_flush = false; } bool &in_flush; }; diff --git a/source/cl/source/extension/include/extension/config.h.in b/source/cl/source/extension/include/extension/config.h.in index 577fdae2e..0bf36c6ee 100644 --- a/source/cl/source/extension/include/extension/config.h.in +++ b/source/cl/source/extension/include/extension/config.h.in @@ -23,7 +23,6 @@ /// @addtogroup cl_extension /// @{ - @generate_extension_defines@ // Total count of all extensions diff --git a/source/cl/source/extension/source/codeplay_performance_counters.cpp b/source/cl/source/extension/source/codeplay_performance_counters.cpp index e541bb0d7..945aad9c1 100644 --- a/source/cl/source/extension/source/codeplay_performance_counters.cpp +++ b/source/cl/source/extension/source/codeplay_performance_counters.cpp @@ -151,8 +151,7 @@ cl_int extension::codeplay_performance_counters::GetEventProfilingInfo( if (auto mux_error = muxGetQueryPoolResults( event->queue->mux_queue, counter_queries, 0, counter_queries->count, sizeof(mux_query_counter_result_t) * counter_queries->count, - static_cast(param_value), - sizeof(mux_query_counter_result_t))) { + param_value, sizeof(mux_query_counter_result_t))) { return cl::getErrorFrom(mux_error); } } diff --git a/source/cl/source/extension/source/extension.cpp.in b/source/cl/source/extension/source/extension.cpp.in index be3da94af..2f25a665e 100644 --- a/source/cl/source/extension/source/extension.cpp.in +++ b/source/cl/source/extension/source/extension.cpp.in @@ -28,8 +28,9 @@ #include namespace { -cargo::array_view getExtensions() { - static cargo::small_vector +cargo::array_view getExtensions() { + static cargo::small_vector extensions; static std::once_flag initialized_flag; @generate_declarations@ @@ -43,23 +44,23 @@ cargo::array_view getExtensions() { return extensions; } -cargo::array_view getRuntimeExtensions() { - static cargo::array_view +cargo::array_view getRuntimeExtensions() { + static cargo::array_view runtime_extensions{getExtensions().data(), CA_CL_RUNTIME_EXTENSION_COUNT}; return runtime_extensions; } -cargo::array_view getCompilerExtensions() { - static cargo::array_view +cargo::array_view getCompilerExtensions() { + static cargo::array_view compiler_extensions{ getExtensions().data() + CA_CL_RUNTIME_EXTENSION_COUNT, CA_CL_COMPILER_EXTENSION_COUNT}; return compiler_extensions; } -void* GetExtensionFunctionAddressForPlatform( - const size_t num_extensions, const extension::extension* const* extensions, - cl_platform_id platform, const char* func_name) { +void *GetExtensionFunctionAddressForPlatform( + const size_t num_extensions, const extension::extension *const *extensions, + cl_platform_id platform, const char *func_name) { OCL_ASSERT( nullptr != platform, "Invalid platform. Expecting caller to map nullptr to a valid platform."); @@ -68,7 +69,7 @@ void* GetExtensionFunctionAddressForPlatform( return nullptr; } - void* function_address = nullptr; + void *function_address = nullptr; for (size_t table_idx = 0; table_idx < num_extensions; ++table_idx) { function_address = extensions[table_idx]->GetExtensionFunctionAddressForPlatform( @@ -92,15 +93,15 @@ void* GetExtensionFunctionAddressForPlatform( template inline cl_int GetObjectExtensionInfoSingleValue( - const size_t num_extensions, const extension::extension* const* extensions, - T object, N param_name, const size_t param_value_size, void* param_value, - size_t* param_value_size_ret, F get_info_fn); + const size_t num_extensions, const extension::extension *const *extensions, + T object, N param_name, const size_t param_value_size, void *param_value, + size_t *param_value_size_ret, F get_info_fn); template inline cl_int GetObjectDetailExtensionInfoSingleValue( - const size_t num_extensions, const extension::extension* const* extensions, + const size_t num_extensions, const extension::extension *const *extensions, T object, D detail, N param_name, const size_t param_value_size, - void* param_value, size_t* param_value_size_ret, F get_info_fn); + void *param_value, size_t *param_value_size_ret, F get_info_fn); template inline cl_int GetObjectDetailExtensionInfoSingleInputValue( @@ -111,9 +112,9 @@ inline cl_int GetObjectDetailExtensionInfoSingleInputValue( template inline cl_int GetObjectExtensionInfoAggregatedCString( - const size_t num_extensions, const extension::extension* const* extensions, - T object, N param_name, const size_t param_value_size, void* param_value, - size_t* param_value_size_ret, const char name_separator, F get_info_fn); + const size_t num_extensions, const extension::extension *const *extensions, + T object, N param_name, const size_t param_value_size, void *param_value, + size_t *param_value_size_ret, const char name_separator, F get_info_fn); /// @brief Query all passed in extensions via the get_info_fn functor/lambda /// until one accepts the query. @@ -147,9 +148,9 @@ inline cl_int GetObjectExtensionInfoAggregatedCString( /// param_name but the supplied argument values are wrong. template cl_int GetObjectExtensionInfoSingleValue( - const size_t num_extensions, const extension::extension* const* extensions, - T object, N param_name, const size_t param_value_size, void* param_value, - size_t* param_value_size_ret, F get_info_fn) { + const size_t num_extensions, const extension::extension *const *extensions, + T object, N param_name, const size_t param_value_size, void *param_value, + size_t *param_value_size_ret, F get_info_fn) { cl_int retcode = CL_INVALID_VALUE; size_t ext_idx = 0; for (ext_idx = 0; ext_idx < num_extensions; ++ext_idx) { @@ -224,9 +225,9 @@ cl_int GetObjectExtensionInfoSingleValue( /// param_name but the supplied argument values are wrong. template cl_int GetObjectDetailExtensionInfoSingleValue( - const size_t num_extensions, const extension::extension* const* extensions, + const size_t num_extensions, const extension::extension *const *extensions, T object, D detail, N param_name, const size_t param_value_size, - void* param_value, size_t* param_value_size_ret, F get_info_fn) { + void *param_value, size_t *param_value_size_ret, F get_info_fn) { cl_int retcode = CL_INVALID_VALUE; size_t ext_idx = 0; for (ext_idx = 0; ext_idx < num_extensions; ++ext_idx) { @@ -375,9 +376,9 @@ cl_int GetObjectDetailExtensionInfoSingleInputValue( /// accepts param_name but the supplied argument values are wrong. template cl_int GetObjectExtensionInfoAggregatedCString( - const size_t num_extensions, const extension::extension* const* extensions, - T object, N param_name, const size_t param_value_size, void* param_value, - size_t* param_value_size_ret, const char name_separator, F get_info_fn) { + const size_t num_extensions, const extension::extension *const *extensions, + T object, N param_name, const size_t param_value_size, void *param_value, + size_t *param_value_size_ret, const char name_separator, F get_info_fn) { // The caller already checked for correctness of the object. cl_int aggregated_retcode = CL_INVALID_VALUE; size_t aggregated_value_size_ret = 0; @@ -421,7 +422,7 @@ cl_int GetObjectExtensionInfoAggregatedCString( // Second pass: query the wanted info and store it in the arguments. if (nullptr != param_value) { - char* value_cursor = static_cast(param_value); + char *value_cursor = static_cast(param_value); size_t value_size_remaining = param_value_size; for (size_t ext_idx = 0; ext_idx < num_extensions; ++ext_idx) { @@ -468,9 +469,9 @@ cl_int GetObjectExtensionInfoAggregatedCString( template cl_int GetObjectExtensionInfoAggregatedArray( - const size_t num_extensions, const extension::extension* const* extensions, - T object, N param_name, const size_t param_value_size, void* param_value, - size_t* param_value_size_ret, F get_info_fn) { + const size_t num_extensions, const extension::extension *const *extensions, + T object, N param_name, const size_t param_value_size, void *param_value, + size_t *param_value_size_ret, F get_info_fn) { cl_int aggregated_retcode = CL_INVALID_VALUE; size_t aggregated_value_size_ret = 0; for (size_t ext_idx = 0; ext_idx < num_extensions; ++ext_idx) { @@ -502,7 +503,7 @@ cl_int GetObjectExtensionInfoAggregatedArray( // Second pass: query the wanted info and store it in the arguments. if (nullptr != param_value) { - char* value_cursor = static_cast(param_value); + char *value_cursor = static_cast(param_value); size_t value_size_remaining = param_value_size; for (size_t ext_idx = 0; ext_idx < num_extensions; ++ext_idx) { @@ -534,7 +535,7 @@ cl_int GetObjectExtensionInfoAggregatedArray( } } // namespace -extension::extension::extension(const char* name, usage_category usage +extension::extension::extension(const char *name, usage_category usage #if defined(CL_VERSION_3_0) , cl_version_khr version @@ -555,12 +556,14 @@ extension::extension::~extension() {} cl_int extension::extension::GetPlatformInfo( cl_platform_id platform, cl_platform_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) const { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) const { OCL_UNUSED(platform); // Already checked by clGetPlatformInfo. if (usage_category::PLATFORM == usage) { switch (param_name) { - default: { return CL_INVALID_VALUE; } + default: { + return CL_INVALID_VALUE; + } case CL_PLATFORM_EXTENSIONS: { const std::size_t size = name.size() + 1; // +1 for zero terminator. OCL_CHECK(nullptr != param_value && param_value_size < size, @@ -591,7 +594,7 @@ cl_int extension::extension::GetPlatformInfo( cargo::small_vector name_version_pairs{}; if (nullptr != param_value) { - for (const auto& extension : split_extensions) { + for (const auto &extension : split_extensions) { cl_name_version_khr name_version{}; name_version.version = version; std::memcpy(name_version.name, extension.data(), extension.size()); @@ -613,19 +616,23 @@ cl_int extension::extension::GetPlatformInfo( cl_int extension::extension::GetDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) const { + void *param_value, + size_t *param_value_size_ret) const { OCL_UNUSED(device); // Already checked by clGetDeviceInfo. if (usage_category::DEVICE == usage || usage_category::PLATFORM == usage) { - // If this is a compiler extension and no compiler is available, then disable it. + // If this is a compiler extension and no compiler is available, then + // disable it. if (!device->compiler_available) { auto compiler_extensions = getCompilerExtensions(); - if (std::find(compiler_extensions.begin(), compiler_extensions.end(), this) != compiler_extensions.end()) { + if (std::find(compiler_extensions.begin(), compiler_extensions.end(), + this) != compiler_extensions.end()) { return CL_INVALID_DEVICE; } } switch (param_name) { - default: { return CL_INVALID_VALUE; } + default: { + return CL_INVALID_VALUE; + } case CL_DEVICE_EXTENSIONS: { const std::size_t size = name.size() + 1; OCL_CHECK(nullptr != param_value && param_value_size < size, @@ -655,7 +662,7 @@ cl_int extension::extension::GetDeviceInfo(cl_device_id device, if (nullptr != param_value) { cargo::small_vector name_version_pairs{}; - for (const auto& extension : split_extensions) { + for (const auto &extension : split_extensions) { cl_name_version_khr name_version{}; name_version.version = version; std::memcpy(name_version.name, extension.data(), extension.size()); @@ -675,7 +682,7 @@ cl_int extension::extension::GetDeviceInfo(cl_device_id device, } cl_int extension::extension::GetContextInfo(cl_context, cl_context_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } @@ -686,56 +693,56 @@ cargo::optional extension::extension::ApplyPropertyToCommandQueue( cl_int extension::extension::GetCommandQueueInfo(cl_command_queue, cl_command_queue_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } -cl_int extension::extension::GetImageInfo(cl_mem, cl_image_info, size_t, void*, - size_t*) const { +cl_int extension::extension::GetImageInfo(cl_mem, cl_image_info, size_t, void *, + size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetMemObjectInfo(cl_mem, cl_mem_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetSamplerInfo(cl_sampler, cl_sampler_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetProgramInfo(cl_program, cl_program_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetProgramBuildInfo(cl_program, cl_device_id, cl_program_build_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetKernelInfo(cl_kernel, cl_kernel_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetKernelWorkGroupInfo(cl_kernel, cl_device_id, cl_kernel_work_group_info, - size_t, void*, - size_t*) const { + size_t, void *, + size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::SetKernelArg(cl_kernel, cl_uint, size_t, - const void*) const { + const void *) const { return CL_INVALID_KERNEL; } cl_int extension::extension::GetKernelArgInfo(cl_kernel, cl_uint, - cl_kernel_arg_info, size_t, void*, - size_t*) const { + cl_kernel_arg_info, size_t, + void *, size_t *) const { return CL_INVALID_VALUE; } @@ -750,37 +757,38 @@ cl_int extension::extension::GetKernelSubGroupInfo(cl_kernel, cl_device_id, #if (defined(CL_VERSION_3_0) || \ defined(OCL_EXTENSION_cl_codeplay_kernel_exec_info)) -cl_int extension::extension::SetKernelExecInfo(cl_kernel, cl_kernel_exec_info_codeplay, - size_t, const void*) const { +cl_int extension::extension::SetKernelExecInfo(cl_kernel, + cl_kernel_exec_info_codeplay, + size_t, const void *) const { return CL_INVALID_KERNEL; } #endif cl_int extension::extension::GetEventInfo(cl_event, cl_event_info, size_t, - void*, size_t*) const { + void *, size_t *) const { return CL_INVALID_VALUE; } cl_int extension::extension::GetEventProfilingInfo(cl_event, cl_profiling_info, - size_t, void*, - size_t*) const { + size_t, void *, + size_t *) const { return CL_INVALID_VALUE; } -void* extension::extension::GetExtensionFunctionAddressForPlatform( - cl_platform_id, const char*) const { +void *extension::extension::GetExtensionFunctionAddressForPlatform( + cl_platform_id, const char *) const { return nullptr; } cl_int extension::GetPlatformInfo(cl_platform_id platform, cl_platform_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { cl_int retcode = CL_INVALID_VALUE; - auto query_fn = [](const extension* extension, cl_platform_id object, + auto query_fn = [](const extension *extension, cl_platform_id object, cl_platform_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetPlatformInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -800,8 +808,8 @@ cl_int extension::GetPlatformInfo(cl_platform_id platform, retcode = GetObjectExtensionInfoAggregatedArray( getExtensions().size(), getExtensions().data(), platform, param_name, param_value_size, param_value, param_value_size_ret, query_fn); - } break; + } #endif default: { // Assuming that yet unknown extension have a single value to query @@ -817,13 +825,13 @@ cl_int extension::GetPlatformInfo(cl_platform_id platform, } cl_int extension::GetDeviceInfo(cl_device_id device, cl_device_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { cl_int retcode = CL_INVALID_VALUE; - auto query_fn = [](const extension* extension, cl_device_id object, + auto query_fn = [](const extension *extension, cl_device_id object, cl_device_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetDeviceInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -843,8 +851,8 @@ cl_int extension::GetDeviceInfo(cl_device_id device, cl_device_info param_name, retcode = GetObjectExtensionInfoAggregatedArray( getExtensions().size(), getExtensions().data(), device, param_name, param_value_size, param_value, param_value_size_ret, query_fn); - } break; + } #endif default: { // Assuming that yet unknown extension have a single value to query @@ -860,11 +868,11 @@ cl_int extension::GetDeviceInfo(cl_device_id device, cl_device_info param_name, } cl_int extension::GetContextInfo(cl_context context, cl_context_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_context object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_context object, cl_context_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetContextInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -889,11 +897,11 @@ cl_int extension::ApplyPropertyToCommandQueue(cl_command_queue command_queue, cl_int extension::GetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name, size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_command_queue object, + void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_command_queue object, cl_command_queue_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetCommandQueueInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -904,11 +912,11 @@ cl_int extension::GetCommandQueueInfo(cl_command_queue command_queue, } cl_int extension::GetImageInfo(cl_mem image, cl_image_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_mem object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_mem object, cl_image_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetImageInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -919,11 +927,11 @@ cl_int extension::GetImageInfo(cl_mem image, cl_image_info param_name, } cl_int extension::GetMemObjectInfo(cl_mem memobj, cl_mem_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_mem object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_mem object, cl_mem_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetMemObjectInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -934,11 +942,11 @@ cl_int extension::GetMemObjectInfo(cl_mem memobj, cl_mem_info param_name, } cl_int extension::GetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_sampler object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_sampler object, cl_sampler_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetSamplerInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -949,11 +957,11 @@ cl_int extension::GetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, } cl_int extension::GetProgramInfo(cl_program program, cl_program_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_program object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_program object, cl_program_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetProgramInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -966,12 +974,12 @@ cl_int extension::GetProgramInfo(cl_program program, cl_program_info param_name, cl_int extension::GetProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_program object, + void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_program object, cl_device_id detail, cl_program_build_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { return extension->GetProgramBuildInfo(object, detail, param_name, param_value_size, param_value, param_value_size_ret); @@ -984,11 +992,11 @@ cl_int extension::GetProgramBuildInfo(cl_program program, cl_device_id device, } cl_int extension::GetKernelInfo(cl_kernel kernel, cl_kernel_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_kernel object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_kernel object, cl_kernel_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetKernelInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -1001,12 +1009,12 @@ cl_int extension::GetKernelInfo(cl_kernel kernel, cl_kernel_info param_name, cl_int extension::GetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_kernel object, + void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_kernel object, cl_device_id detail, cl_kernel_work_group_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { return extension->GetKernelWorkGroupInfo(object, detail, param_name, param_value_size, param_value, param_value_size_ret); @@ -1019,7 +1027,7 @@ cl_int extension::GetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, } cl_int extension::SetKernelArg(cl_kernel kernel, cl_uint arg_index, - size_t arg_size, const void* arg_value) { + size_t arg_size, const void *arg_value) { for (auto extension : getExtensions()) { auto error = extension->SetKernelArg(kernel, arg_index, arg_size, arg_value); @@ -1032,12 +1040,12 @@ cl_int extension::SetKernelArg(cl_kernel kernel, cl_uint arg_index, cl_int extension::GetKernelArgInfo(cl_kernel kernel, cl_uint arg_indx, cl_kernel_arg_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_kernel object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_kernel object, cl_uint detail, cl_kernel_arg_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { return extension->GetKernelArgInfo(object, detail, param_name, param_value_size, param_value, param_value_size_ret); @@ -1076,11 +1084,10 @@ cl_int extension::GetKernelSubGroupInfo( cl_int extension::SetKernelExecInfo(cl_kernel kernel, cl_kernel_exec_info_codeplay param_name, size_t param_value_size, - const void* param_value) { + const void *param_value) { for (auto extension : getExtensions()) { - auto error = - extension->SetKernelExecInfo(kernel, param_name, param_value_size, - param_value); + auto error = extension->SetKernelExecInfo(kernel, param_name, + param_value_size, param_value); if (error != CL_INVALID_KERNEL) { return error; } @@ -1090,11 +1097,11 @@ cl_int extension::SetKernelExecInfo(cl_kernel kernel, #endif cl_int extension::GetEventInfo(cl_event event, cl_event_info param_name, - size_t param_value_size, void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_event object, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_event object, cl_event_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetEventInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -1107,11 +1114,11 @@ cl_int extension::GetEventInfo(cl_event event, cl_event_info param_name, cl_int extension::GetEventProfilingInfo(cl_event event, cl_profiling_info param_name, size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) { - auto query_fn = [](const extension* extension, cl_event object, + void *param_value, + size_t *param_value_size_ret) { + auto query_fn = [](const extension *extension, cl_event object, cl_profiling_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetEventProfilingInfo(object, param_name, param_value_size, param_value, param_value_size_ret); @@ -1122,22 +1129,22 @@ cl_int extension::GetEventProfilingInfo(cl_event event, param_value_size, param_value, param_value_size_ret, query_fn); } -void* extension::GetExtensionFunctionAddressForPlatform(cl_platform_id platform, - const char* func_name) { +void *extension::GetExtensionFunctionAddressForPlatform(cl_platform_id platform, + const char *func_name) { return ::GetExtensionFunctionAddressForPlatform( getExtensions().size(), getExtensions().data(), platform, func_name); } [[nodiscard]] cl_int extension::GetRuntimeExtensionsForDevice( - cl_device_id device, cargo::string_view& extensions_ret) { + cl_device_id device, cargo::string_view &extensions_ret) { static std::string extensions{}; static std::once_flag initialized_flag{}; static cl_int retcode = CL_SUCCESS; std::call_once(initialized_flag, [&]() { - auto query_fn = [](const extension* extension, cl_device_id object, + auto query_fn = [](const extension *extension, cl_device_id object, cl_device_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetDeviceInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; @@ -1174,15 +1181,15 @@ void* extension::GetExtensionFunctionAddressForPlatform(cl_platform_id platform, } [[nodiscard]] cl_int extension::GetCompilerExtensionsForDevice( - cl_device_id device, cargo::string_view& extensions_ret) { + cl_device_id device, cargo::string_view &extensions_ret) { static std::string extensions{}; static std::once_flag initialized_flag{}; static cl_int retcode = CL_SUCCESS; std::call_once(initialized_flag, [&]() { - auto query_fn = [](const extension* extension, cl_device_id object, + auto query_fn = [](const extension *extension, cl_device_id object, cl_device_info param_name, size_t param_value_size, - void* param_value, size_t* param_value_size_ret) { + void *param_value, size_t *param_value_size_ret) { return extension->GetDeviceInfo(object, param_name, param_value_size, param_value, param_value_size_ret); }; diff --git a/source/cl/source/extension/source/intel_unified_shared_memory/intel_unified_shared_memory.cpp b/source/cl/source/extension/source/intel_unified_shared_memory/intel_unified_shared_memory.cpp index dd1b53d95..a1693e9a1 100644 --- a/source/cl/source/extension/source/intel_unified_shared_memory/intel_unified_shared_memory.cpp +++ b/source/cl/source/extension/source/intel_unified_shared_memory/intel_unified_shared_memory.cpp @@ -29,13 +29,13 @@ namespace usm { // // A valid alignment is a possibly 0 power of two. This function does not check // for device support. -constexpr bool isAlignmentValid(cl_uint alignment) { +static constexpr bool isAlignmentValid(cl_uint alignment) { return !alignment || (alignment & (alignment - 1)) == 0; } /// Return whether multiple bits are set for the given value template -constexpr bool areMultipleBitsSet(T value) { +static constexpr bool areMultipleBitsSet(T value) { return value && (value & (value - 1)) != 0; } @@ -213,8 +213,7 @@ host_allocation_info::~host_allocation_info() { mux_buffer_t mux_buffer = mux_buffers[index]; if (mux_buffer) { - (void)muxDestroyBuffer(device->mux_device, mux_buffer, - device->mux_allocator); + muxDestroyBuffer(device->mux_device, mux_buffer, device->mux_allocator); } mux_memory_t mux_memory = mux_memories[index]; @@ -340,8 +339,7 @@ device_allocation_info::device_allocation_info(const cl_context context, device_allocation_info::~device_allocation_info() { if (mux_buffer) { - (void)muxDestroyBuffer(device->mux_device, mux_buffer, - device->mux_allocator); + muxDestroyBuffer(device->mux_device, mux_buffer, device->mux_allocator); } if (mux_memory) { @@ -440,8 +438,7 @@ shared_allocation_info::shared_allocation_info(const cl_context context, shared_allocation_info::~shared_allocation_info() { if (mux_buffer) { assert(device); - (void)muxDestroyBuffer(device->mux_device, mux_buffer, - device->mux_allocator); + muxDestroyBuffer(device->mux_device, mux_buffer, device->mux_allocator); } if (mux_memory) { diff --git a/source/cl/source/extension/source/intel_unified_shared_memory/usm-exports.cpp b/source/cl/source/extension/source/intel_unified_shared_memory/usm-exports.cpp index e6c1d9d63..4d5d18dcf 100644 --- a/source/cl/source/extension/source/intel_unified_shared_memory/usm-exports.cpp +++ b/source/cl/source/extension/source/intel_unified_shared_memory/usm-exports.cpp @@ -482,8 +482,8 @@ cl_int clSetKernelArgMemPointerINTEL(cl_kernel kernel, cl_uint arg_index, // The cl_intel_unified_shared_memory specification has an open question on // whether unknown pointers should be accepted. We accept them since the SYCL // specification and the SYCL CTS imply this must be treated as valid. - kernel->saved_args[arg_index] = - _cl_kernel::argument(*arg_type, &arg_value, sizeof(void *)); + kernel->saved_args[arg_index] = _cl_kernel::argument( + *arg_type, static_cast(&arg_value), sizeof(void *)); return CL_SUCCESS; } diff --git a/source/cl/source/extension/source/khr_command_buffer.cpp b/source/cl/source/extension/source/khr_command_buffer.cpp index 598780020..1602031f3 100644 --- a/source/cl/source/extension/source/khr_command_buffer.cpp +++ b/source/cl/source/extension/source/khr_command_buffer.cpp @@ -1156,7 +1156,8 @@ cargo::expected createArgumentDescriptor( mux_descriptor_info_s descriptor; descriptor.type = mux_descriptor_info_type_e::mux_descriptor_info_type_plain_old_data; - descriptor.plain_old_data_descriptor.data = &update_info.pointers[i]; + descriptor.plain_old_data_descriptor.data = + static_cast(&update_info.pointers[i]); descriptor.plain_old_data_descriptor.length = sizeof update_info.pointers[i]; update_info.pointers[i] = arg_value; diff --git a/source/cl/source/kernel.cpp b/source/cl/source/kernel.cpp index 405bb26d4..e80e97ec1 100644 --- a/source/cl/source/kernel.cpp +++ b/source/cl/source/kernel.cpp @@ -1175,7 +1175,7 @@ CL_API_ENTRY cl_int CL_API_CALL cl::GetKernelInfo( /// @brief Converts a kernel argument address space from the compiler library to /// an OpenCL argument address qualifier. -cl_kernel_arg_address_qualifier convertKernelAddressQualifier( +static cl_kernel_arg_address_qualifier convertKernelAddressQualifier( compiler::AddressSpace address) { switch (address) { case compiler::AddressSpace::PRIVATE: @@ -1192,7 +1192,7 @@ cl_kernel_arg_address_qualifier convertKernelAddressQualifier( /// @brief Converts a kernel argument access qualifier from the compiler library /// to an OpenCL argument access qualifier. -cl_kernel_arg_access_qualifier convertKernelArgAccessQualifier( +static cl_kernel_arg_access_qualifier convertKernelArgAccessQualifier( compiler::KernelArgAccess access) { switch (access) { case compiler::KernelArgAccess::NONE: @@ -1209,7 +1209,8 @@ cl_kernel_arg_access_qualifier convertKernelArgAccessQualifier( /// @brief Converts a kernel argument type qualifier from the compiler library /// to an OpenCL argument type qualifier. -cl_kernel_arg_type_qualifier convertKernelArgTypeQualifier(std::uint32_t type) { +static cl_kernel_arg_type_qualifier convertKernelArgTypeQualifier( + std::uint32_t type) { cl_uint cl_arg_type = 0; if (type & compiler::KernelArgType::CONST) { cl_arg_type |= CL_KERNEL_ARG_TYPE_CONST; diff --git a/source/cl/source/mem.cpp b/source/cl/source/mem.cpp index c7615890a..7d1129d21 100644 --- a/source/cl/source/mem.cpp +++ b/source/cl/source/mem.cpp @@ -550,7 +550,7 @@ cl::EnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, // if this is a write mapping we need to flush the memory region to // the device if (mem->write_mappings.end() != it) { - _cl_mem::mapping const &map = it->second; + const _cl_mem::mapping &map = it->second; if (CL_MEM_USE_HOST_PTR & mem->flags) { // Copy data from `host_ptr` user has accessed/modified to our diff --git a/source/cl/source/validate.cpp b/source/cl/source/validate.cpp index 5c31ab049..1dfd75b60 100644 --- a/source/cl/source/validate.cpp +++ b/source/cl/source/validate.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -160,7 +161,7 @@ cl_int CopyBufferArguments(cl_command_queue command_queue, cl_mem src_buffer, // ranges here as right-open intervals, i.e [START, END). #define IN_RANGE(X, START, END) (((X) >= (START)) && ((X) < (END))) #define RANGES_OVERLAP(STARTX, ENDX, STARTY, ENDY) \ - (IN_RANGE(STARTY, STARTX, ENDX) || IN_RANGE((ENDY)-1, STARTX, ENDX)) + (IN_RANGE(STARTY, STARTX, ENDX) || IN_RANGE((ENDY) - 1, STARTX, ENDX)) OCL_CHECK(RANGES_OVERLAP(src_start, src_start + size, dst_start, dst_start + size), return CL_MEM_COPY_OVERLAP); diff --git a/source/cl/test/BenchCL/source/buffer.cpp b/source/cl/test/BenchCL/source/buffer.cpp index 2dc0b57d6..e6300bdf8 100644 --- a/source/cl/test/BenchCL/source/buffer.cpp +++ b/source/cl/test/BenchCL/source/buffer.cpp @@ -21,7 +21,7 @@ #include -void BufferReadRect(benchmark::State &state) { +static void BufferReadRect(benchmark::State &state) { auto device = benchcl::env::get()->device; auto status = CL_SUCCESS; @@ -58,7 +58,7 @@ void BufferReadRect(benchmark::State &state) { } BENCHMARK(BufferReadRect)->Arg(1)->Arg(256)->Arg(512); -void BufferWriteRect(benchmark::State &state) { +static void BufferWriteRect(benchmark::State &state) { auto device = benchcl::env::get()->device; auto status = CL_SUCCESS; diff --git a/source/cl/test/BenchCL/source/kernel.cpp b/source/cl/test/BenchCL/source/kernel.cpp index 1825585b8..d207da059 100644 --- a/source/cl/test/BenchCL/source/kernel.cpp +++ b/source/cl/test/BenchCL/source/kernel.cpp @@ -39,7 +39,7 @@ struct CreateData { } }; -CreateData create_data_from_source(const std::string &source) { +static CreateData create_data_from_source(const std::string &source) { cl_platform_id platform; cl_device_id device; cl_context context; @@ -63,8 +63,8 @@ CreateData create_data_from_source(const std::string &source) { return CreateData{platform, device, context, program}; } -CreateData create_data_from_binary(const std::string &binary_32, - const std::string &binary_64) { +static CreateData create_data_from_binary(const std::string &binary_32, + const std::string &binary_64) { cl_platform_id platform; cl_device_id device; cl_context context; @@ -107,7 +107,7 @@ CreateData create_data_from_binary(const std::string &binary_32, return CreateData{platform, device, context, program}; } -void KernelCreateFirstKernelInSource(benchmark::State &state) { +static void KernelCreateFirstKernelInSource(benchmark::State &state) { std::string source; for (unsigned i = 0; i < state.range(0); i++) { @@ -127,7 +127,7 @@ void KernelCreateFirstKernelInSource(benchmark::State &state) { } BENCHMARK(KernelCreateFirstKernelInSource)->Arg(1)->Arg(256)->Arg(16384); -void KernelCreateLastKernelInSource(benchmark::State &state) { +static void KernelCreateLastKernelInSource(benchmark::State &state) { std::string source; for (unsigned i = 0; i < state.range(0); i++) { @@ -147,7 +147,7 @@ void KernelCreateLastKernelInSource(benchmark::State &state) { } BENCHMARK(KernelCreateLastKernelInSource)->Arg(1)->Arg(256)->Arg(16384); -void KernelCreateWithRequiredWorkGroupSize(benchmark::State &state) { +static void KernelCreateWithRequiredWorkGroupSize(benchmark::State &state) { const std::string source = "kernel __attribute__((reqd_work_group_size(1, 1, 1)))" " void func() {}\n"; @@ -164,7 +164,7 @@ void KernelCreateWithRequiredWorkGroupSize(benchmark::State &state) { } BENCHMARK(KernelCreateWithRequiredWorkGroupSize); -void KernelEnqueueEmpty(benchmark::State &state) { +static void KernelEnqueueEmpty(benchmark::State &state) { const std::string source = "kernel void empty() {}"; const CreateData cd = create_data_from_source(source); @@ -206,7 +206,7 @@ void KernelEnqueueEmpty(benchmark::State &state) { } BENCHMARK(KernelEnqueueEmpty)->UseManualTime(); -void KernelTiledEnqueue(benchmark::State &state) { +static void KernelTiledEnqueue(benchmark::State &state) { const std::string source = R"CL( __kernel void vector_addition(__global int *src1, __global int *src2, __global int *dst) { @@ -221,7 +221,6 @@ void KernelTiledEnqueue(benchmark::State &state) { auto err = cl_int{CL_SUCCESS}; const CreateData cd = create_data_from_source(source); - const std::string name = "vector_addition"; constexpr size_t bytes = sizeof(cl_int) * item_count; @@ -239,12 +238,12 @@ void KernelTiledEnqueue(benchmark::State &state) { /* Create kernel and set arguments */ cl_kernel ker = clCreateKernel(cd.program, "vector_addition", &err); ASSERT_EQ_ERRCODE(CL_SUCCESS, err); - ASSERT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(ker, 0, sizeof(src1_buf), &src1_buf)); - ASSERT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(ker, 1, sizeof(src2_buf), &src2_buf)); - ASSERT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(ker, 2, sizeof(dst_buf), &dst_buf)); + ASSERT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(ker, 0, sizeof(src1_buf), + static_cast(&src1_buf))); + ASSERT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(ker, 1, sizeof(src2_buf), + static_cast(&src2_buf))); + ASSERT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(ker, 2, sizeof(dst_buf), + static_cast(&dst_buf))); /* Create command queue */ cl_command_queue qu = clCreateCommandQueue(ctx, cd.device, 0, &err); @@ -318,7 +317,7 @@ BENCHMARK(KernelTiledEnqueue) ->UseManualTime(); // Nothing special about these values, just more tiles. -void KernelCreateEmptyKernelFromSource(benchmark::State &state) { +static void KernelCreateEmptyKernelFromSource(benchmark::State &state) { const std::string source = "kernel void empty() {}"; const CreateData cd = create_data_from_source(source); @@ -347,7 +346,7 @@ void KernelCreateEmptyKernelFromSource(benchmark::State &state) { } BENCHMARK(KernelCreateEmptyKernelFromSource); -void KernelCreateEmptyKernelFromBinary(benchmark::State &state) { +static void KernelCreateEmptyKernelFromBinary(benchmark::State &state) { /* create with xxd, 'kernel void empty() {}' */ unsigned char empty_bc64[] = { 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x16, 0x01, 0x00, 0x00, diff --git a/source/cl/test/BenchCL/source/program.cpp b/source/cl/test/BenchCL/source/program.cpp index f31e31c3f..ebf3e3dc4 100644 --- a/source/cl/test/BenchCL/source/program.cpp +++ b/source/cl/test/BenchCL/source/program.cpp @@ -48,6 +48,7 @@ template <> std::vector CreateProgramData::generate( unsigned s) { std::vector data; + data.reserve(s); for (unsigned i = 0; i < s; i++) { data.push_back(""); } diff --git a/source/cl/test/BenchCL/source/queue.cpp b/source/cl/test/BenchCL/source/queue.cpp index f759d7bdd..fa4dfaec0 100644 --- a/source/cl/test/BenchCL/source/queue.cpp +++ b/source/cl/test/BenchCL/source/queue.cpp @@ -64,10 +64,10 @@ struct CreateData { &status); ASSERT_EQ_ERRCODE(CL_SUCCESS, status); - ASSERT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &out)); - ASSERT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 1, sizeof(cl_mem), &in)); + ASSERT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&out))); + ASSERT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&in))); queue = clCreateCommandQueue(context, device, 0, &status); ASSERT_EQ_ERRCODE(CL_SUCCESS, status); @@ -83,7 +83,7 @@ struct CreateData { } }; -void SingleThreadOneQueueNoDependencies(benchmark::State &state) { +static void SingleThreadOneQueueNoDependencies(benchmark::State &state) { const CreateData cd; for (auto _ : state) { @@ -101,7 +101,7 @@ void SingleThreadOneQueueNoDependencies(benchmark::State &state) { } BENCHMARK(SingleThreadOneQueueNoDependencies)->Arg(1)->Arg(256)->Arg(1024); -void SingleThreadOneQueue(benchmark::State &state) { +static void SingleThreadOneQueue(benchmark::State &state) { const CreateData cd; for (auto _ : state) { @@ -126,7 +126,7 @@ void SingleThreadOneQueue(benchmark::State &state) { } BENCHMARK(SingleThreadOneQueue)->Arg(1)->Arg(256)->Arg(1024); -void MultiThreadOneQueueNoDependencies(benchmark::State &state) { +static void MultiThreadOneQueueNoDependencies(benchmark::State &state) { const CreateData cd; for (auto _ : state) { @@ -148,7 +148,7 @@ BENCHMARK(MultiThreadOneQueueNoDependencies) ->Arg(1024) ->Threads(std::thread::hardware_concurrency()); -void MultiThreadOneQueue(benchmark::State &state) { +static void MultiThreadOneQueue(benchmark::State &state) { const CreateData cd; for (auto _ : state) { @@ -177,7 +177,7 @@ BENCHMARK(MultiThreadOneQueue) ->Arg(1024) ->Threads(std::thread::hardware_concurrency()); -void MultiThreadMultiQueueNoDependencies(benchmark::State &state) { +static void MultiThreadMultiQueueNoDependencies(benchmark::State &state) { const CreateData cd; cl_command_queue queue; @@ -211,7 +211,7 @@ BENCHMARK(MultiThreadMultiQueueNoDependencies) ->Arg(1024) ->Threads(std::thread::hardware_concurrency()); -void MultiThreadMultiQueue(benchmark::State &state) { +static void MultiThreadMultiQueue(benchmark::State &state) { const CreateData cd; cl_command_queue queue; diff --git a/source/cl/test/FuzzCL/include/FuzzCL/context.h b/source/cl/test/FuzzCL/include/FuzzCL/context.h index 5f17b0a42..b83b6ad4a 100644 --- a/source/cl/test/FuzzCL/include/FuzzCL/context.h +++ b/source/cl/test/FuzzCL/include/FuzzCL/context.h @@ -134,7 +134,7 @@ struct input_t { assert(min <= max); // Return min if there is not enough data left if (index < data.size()) { - return min + data[index++] % (max - min + 1); + return min + (data[index++] % (max - min + 1)); } else { return min; } diff --git a/source/cl/test/FuzzCL/source/context.cpp b/source/cl/test/FuzzCL/source/context.cpp index cb3b038a0..9b14fa249 100644 --- a/source/cl/test/FuzzCL/source/context.cpp +++ b/source/cl/test/FuzzCL/source/context.cpp @@ -843,8 +843,8 @@ void fuzzcl::enqueueCopyImageToBuffer(context_t &fc, fuzzcl::input_t &input) { // in bytes const size_t dst_offset = - input.next(0, BUFFER_SIZE - image_src_origin_ptr->at(0) * - image_src_origin_ptr->at(1)) * + input.next(0, BUFFER_SIZE - (image_src_origin_ptr->at(0) * + image_src_origin_ptr->at(1))) * sizeof(cl_int); std::unique_lock lock(fc.mutex); @@ -907,8 +907,8 @@ void fuzzcl::enqueueCopyBufferToImage(fuzzcl::context_t &fc, // in bytes const size_t src_offset = - input.next(0, BUFFER_SIZE - image_dst_origin_ptr->at(0) * - image_dst_origin_ptr->at(1)) * + input.next(0, BUFFER_SIZE - (image_dst_origin_ptr->at(0) * + image_dst_origin_ptr->at(1))) * sizeof(cl_int); std::unique_lock lock(fc.mutex); @@ -1090,7 +1090,7 @@ void fuzzcl::enqueueTask(fuzzcl::context_t &fc, fuzzcl::input_t &input) { } /// @brief The callback used by fuzzcl::setEventCallback -void CL_CALLBACK callback(cl_event, cl_int, void *user_data) { +static void CL_CALLBACK callback(cl_event, cl_int, void *user_data) { const fuzzcl::callback_input_data_t callback_input_data = *static_cast(user_data); run_input(*callback_input_data.fc, callback_input_data.input); @@ -1149,6 +1149,7 @@ void fuzzcl::setEventCallback(fuzzcl::context_t &fc, fuzzcl::input_t &input) { input.next(0, std::min(MAX_CALLBACK_INPUT_SIZE, int(input.data.size() - input.index - 1))); std::vector callback_data; + callback_data.reserve(callback_data_size); for (size_t i = 0; i < callback_data_size; i++) { callback_data.emplace_back(input.next()); } diff --git a/source/cl/test/FuzzCL/source/fuzz.cpp b/source/cl/test/FuzzCL/source/fuzz.cpp index bc1bf6d2a..ad2f5478b 100644 --- a/source/cl/test/FuzzCL/source/fuzz.cpp +++ b/source/cl/test/FuzzCL/source/fuzz.cpp @@ -54,7 +54,7 @@ struct arguments_t { /// @param[in] argv Argument array /// /// @return Returns the parsed dictionnary -arguments_t parse_arguments(int argc, char *argv[]) { +static arguments_t parse_arguments(int argc, char *argv[]) { cargo::argument_parser<1> parser; cargo::string_view file; diff --git a/source/cl/test/MultiDevice/source/command_queue.cpp b/source/cl/test/MultiDevice/source/command_queue.cpp index a1db029f4..522222f08 100644 --- a/source/cl/test/MultiDevice/source/command_queue.cpp +++ b/source/cl/test/MultiDevice/source/command_queue.cpp @@ -22,15 +22,17 @@ TEST_F(MultiDeviceCommandQueue, Info) { std::vector queueDevices; for (auto command_queue : command_queues) { cl_context queueContext; - ASSERT_EQ(CL_SUCCESS, clGetCommandQueueInfo(command_queue, CL_QUEUE_CONTEXT, - sizeof(cl_context), - &queueContext, nullptr)); + ASSERT_EQ(CL_SUCCESS, + clGetCommandQueueInfo( + command_queue, CL_QUEUE_CONTEXT, sizeof(cl_context), + static_cast(&queueContext), nullptr)); ASSERT_EQ(context, queueContext) << "The command queue was created with a different context.\n"; cl_device_id queueDevice; - ASSERT_EQ(CL_SUCCESS, clGetCommandQueueInfo(command_queue, CL_QUEUE_DEVICE, - sizeof(cl_device_id), - &queueDevice, nullptr)); + ASSERT_EQ(CL_SUCCESS, + clGetCommandQueueInfo( + command_queue, CL_QUEUE_DEVICE, sizeof(cl_device_id), + static_cast(&queueDevice), nullptr)); ASSERT_EQ(queueDevices.end(), std::find(queueDevices.begin(), queueDevices.end(), queueDevice)) << "The command queue has the same device as another command queue but " diff --git a/source/cl/test/MultiDevice/source/context.cpp b/source/cl/test/MultiDevice/source/context.cpp index adaff3b2a..51b850cc4 100644 --- a/source/cl/test/MultiDevice/source/context.cpp +++ b/source/cl/test/MultiDevice/source/context.cpp @@ -20,7 +20,7 @@ TEST_F(MultiDeviceContext, CreateBuffer) { cl_context bufferContext; EXPECT_EQ(CL_SUCCESS, clGetMemObjectInfo(buffer, CL_MEM_CONTEXT, sizeof(cl_context), - &bufferContext, nullptr)); + static_cast(&bufferContext), nullptr)); EXPECT_EQ(context, bufferContext); ASSERT_EQ(CL_SUCCESS, clReleaseMemObject(buffer)); } @@ -49,7 +49,7 @@ TEST_F(MultiDeviceContext, CreateImage) { cl_context imageContext; EXPECT_EQ(CL_SUCCESS, clGetMemObjectInfo(image, CL_MEM_CONTEXT, sizeof(cl_context), - &imageContext, nullptr)); + static_cast(&imageContext), nullptr)); EXPECT_EQ(context, imageContext); ASSERT_EQ(CL_SUCCESS, clReleaseMemObject(image)); } diff --git a/source/cl/test/UnitCL/include/Common.h.in b/source/cl/test/UnitCL/include/Common.h.in index 1d8974ac6..430d3a473 100644 --- a/source/cl/test/UnitCL/include/Common.h.in +++ b/source/cl/test/UnitCL/include/Common.h.in @@ -103,10 +103,10 @@ struct aligned_allocator { void deallocate(T *p, size_t n) { (void)n; - UCL::aligned_free(p); + UCL::aligned_free(static_cast(p)); } - aligned_allocator(){}; + aligned_allocator() {}; template struct rebind { using other = aligned_allocator; diff --git a/source/cl/test/UnitCL/include/Device.h.in b/source/cl/test/UnitCL/include/Device.h.in index 64cc1064b..3c454d086 100644 --- a/source/cl/test/UnitCL/include/Device.h.in +++ b/source/cl/test/UnitCL/include/Device.h.in @@ -17,9 +17,8 @@ #ifndef UNITCL_DEVICE_H #define UNITCL_DEVICE_H -#include "Common.h" - #include "CL/cl.h" +#include "Common.h" namespace UCL { inline bool isDevice_IntelNeo(cl_device_id device) { diff --git a/source/cl/test/UnitCL/include/cl_codeplay_wfv.h b/source/cl/test/UnitCL/include/cl_codeplay_wfv.h index 3d57f1b50..e95511563 100644 --- a/source/cl/test/UnitCL/include/cl_codeplay_wfv.h +++ b/source/cl/test/UnitCL/include/cl_codeplay_wfv.h @@ -99,7 +99,8 @@ struct cl_codeplay_wfv_BinaryTest : cl_codeplay_wfv_Test { unsigned char *binaries[] = {binary.data()}; const unsigned char *binaries_const[] = {binary.data()}; ASSERT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, - sizeof(binaries), binaries, nullptr)); + sizeof(binaries), + static_cast(binaries), nullptr)); ASSERT_SUCCESS(clReleaseProgram(program)); cl_int status; cl_int error; diff --git a/source/cl/test/UnitCL/include/cl_intel_unified_shared_memory.h b/source/cl/test/UnitCL/include/cl_intel_unified_shared_memory.h index 7f73795d3..51965fd60 100644 --- a/source/cl/test/UnitCL/include/cl_intel_unified_shared_memory.h +++ b/source/cl/test/UnitCL/include/cl_intel_unified_shared_memory.h @@ -135,7 +135,7 @@ struct cl_intel_unified_shared_memory_Test : public virtual ucl::ContextTest { return to_return; } - constexpr static size_t MAX_NUM_POINTERS = 3; + static constexpr size_t MAX_NUM_POINTERS = 3; void *host_ptr = nullptr; void *shared_ptr = nullptr; void *host_shared_ptr = nullptr; diff --git a/source/cl/test/UnitCL/include/kts/arguments.h b/source/cl/test/UnitCL/include/kts/arguments.h index 63222aa39..bb00cff53 100644 --- a/source/cl/test/UnitCL/include/kts/arguments.h +++ b/source/cl/test/UnitCL/include/kts/arguments.h @@ -523,7 +523,7 @@ struct MemoryAccessor<::ucl::PackedVector3Type> { vector_type LoadFromBuffer(void *Ptr, size_t Offset) { void *const PtrPlusOffset = - static_cast(Ptr) + 3 * Offset * sizeof(value_type); + static_cast(Ptr) + (3 * Offset * sizeof(value_type)); vector_type Val; memcpy(Val.data(), PtrPlusOffset, 3 * sizeof(value_type)); return Val; @@ -531,7 +531,7 @@ struct MemoryAccessor<::ucl::PackedVector3Type> { void StoreToBuffer(const vector_type &Val, void *Ptr, size_t Offset) { void *const PtrPlusOffset = - static_cast(Ptr) + 3 * Offset * sizeof(value_type); + static_cast(Ptr) + (3 * Offset * sizeof(value_type)); memcpy(PtrPlusOffset, Val.data(), 3 * sizeof(value_type)); } }; diff --git a/source/cl/test/UnitCL/include/kts/generator.h b/source/cl/test/UnitCL/include/kts/generator.h index dde024ee8..a1828ad80 100644 --- a/source/cl/test/UnitCL/include/kts/generator.h +++ b/source/cl/test/UnitCL/include/kts/generator.h @@ -250,7 +250,7 @@ void InputGenerator::GenerateIntData(std::vector &buffer, T min, T max) { // then cast back the result. using LargerType = std::conditional_t< std::is_same_v, uint8_t>, - std::conditional_t::value, uint32_t, int32_t>, T>; + std::conditional_t, uint32_t, int32_t>, T>; std::uniform_int_distribution dist(min, max); std::generate(buffer.begin(), buffer.end(), @@ -317,7 +317,7 @@ T InputGenerator::GenerateInt(T min, T max) { // then cast back the result. using LargerType = std::conditional_t< std::is_same_v, uint8_t>, - std::conditional_t::value, uint32_t, int32_t>, T>; + std::conditional_t, uint32_t, int32_t>, T>; std::uniform_int_distribution dist(min, max); return static_cast(dist(gen_)); } diff --git a/source/cl/test/UnitCL/include/kts/type_info.h b/source/cl/test/UnitCL/include/kts/type_info.h index ecdd7da94..ae59f4787 100644 --- a/source/cl/test/UnitCL/include/kts/type_info.h +++ b/source/cl/test/UnitCL/include/kts/type_info.h @@ -39,7 +39,7 @@ struct TypeInfo { using LargerType = cl_float; static const unsigned mantissa_bits = 10; - const static int bias = 15; + static const int bias = 15; static const AsUnsigned mantissa_mask = 0x03FF; static const AsUnsigned exponent_mask = 0x7C00; @@ -65,7 +65,7 @@ struct TypeInfo { using LargerType = cl_double; static const unsigned mantissa_bits = 23; - const static int bias = 127; + static const int bias = 127; static const AsUnsigned mantissa_mask = 0x007FFFFF; static const AsUnsigned exponent_mask = 0x7F800000; diff --git a/source/cl/test/UnitCL/include/ucl/file.h b/source/cl/test/UnitCL/include/ucl/file.h index d5bb4d6a8..8ad0951d7 100644 --- a/source/cl/test/UnitCL/include/ucl/file.h +++ b/source/cl/test/UnitCL/include/ucl/file.h @@ -39,9 +39,12 @@ struct File { Container content; using value_type = typename Container::value_type; std::array buffer; - while (const size_t objects = std::fread(buffer.data(), sizeof(value_type), - buffer.size(), file)) { + constexpr size_t buffer_size = buffer.size(); + for (;;) { + const size_t objects = + std::fread(buffer.data(), sizeof(value_type), buffer_size, file); content.insert(content.end(), buffer.data(), buffer.data() + objects); + if (objects < buffer_size) break; } return content; } diff --git a/source/cl/test/UnitCL/include/ucl/version.h b/source/cl/test/UnitCL/include/ucl/version.h index 7b69c7448..bfb5067c0 100644 --- a/source/cl/test/UnitCL/include/ucl/version.h +++ b/source/cl/test/UnitCL/include/ucl/version.h @@ -38,7 +38,7 @@ namespace ucl { struct Version { Version() = default; Version(int major, int minor) - : Major(major), Minor(minor), Scaled(major * 100 + minor * 10) {} + : Major(major), Minor(minor), Scaled((major * 100) + (minor * 10)) {} bool operator==(const Version &rhs) const { return Scaled == rhs.Scaled; } bool operator!=(const Version &rhs) const { return Scaled != rhs.Scaled; } diff --git a/source/cl/test/UnitCL/source/C11Atomics.cpp b/source/cl/test/UnitCL/source/C11Atomics.cpp index 75138b1cc..b9f35b547 100644 --- a/source/cl/test/UnitCL/source/C11Atomics.cpp +++ b/source/cl/test/UnitCL/source/C11Atomics.cpp @@ -612,12 +612,12 @@ class FetchTest : public C11AtomicTestBase { }; template -T zeroReference(size_t, const std::vector &) { +static T zeroReference(size_t, const std::vector &) { return T{0}; } template -T firstEltReference(size_t, const std::vector &input) { +static T firstEltReference(size_t, const std::vector &input) { return input[0]; } diff --git a/source/cl/test/UnitCL/source/KernelArgumentTypes.cpp b/source/cl/test/UnitCL/source/KernelArgumentTypes.cpp index 98e46d30e..88e4b911c 100644 --- a/source/cl/test/UnitCL/source/KernelArgumentTypes.cpp +++ b/source/cl/test/UnitCL/source/KernelArgumentTypes.cpp @@ -126,8 +126,10 @@ TYPED_TEST(KernelArgumentTypesTest, ByGlobalPointer) { EXPECT_TRUE(kernel); ASSERT_SUCCESS(errorcode); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&outMem)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&inMem)); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&outMem))); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 1, sizeof(cl_mem), static_cast(&inMem))); EXPECT_SUCCESS( clEnqueueTask(this->command_queue, kernel, 0, nullptr, nullptr)); @@ -188,8 +190,10 @@ TYPED_TEST(KernelArgumentTypesTest, ByConstantPointer) { EXPECT_TRUE(kernel); EXPECT_SUCCESS(errorcode); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&outMem)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&inMem)); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&outMem))); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 1, sizeof(cl_mem), static_cast(&inMem))); EXPECT_SUCCESS( clEnqueueTask(this->command_queue, kernel, 0, nullptr, nullptr)); @@ -245,7 +249,8 @@ TYPED_TEST(KernelArgumentTypesTest, ByValue) { ASSERT_SUCCESS(status); // set kernel args - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &outBuffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&outBuffer))); // Redmine #5143: set this to some actual value static_assert(std::is_trivial::value, @@ -344,7 +349,8 @@ TYPED_TEST(KernelArgumentTypesTest, ByLocalPointer) { EXPECT_TRUE(kernel); EXPECT_SUCCESS(errorcode); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&outMem)); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&outMem))); EXPECT_EQ(CL_SUCCESS, clSetKernelArg(kernel, 1, sizeof(typename TestFixture::TestType), nullptr)); diff --git a/source/cl/test/UnitCL/source/arm64Regression.cpp b/source/cl/test/UnitCL/source/arm64Regression.cpp index 126b70f04..1cd6ce61d 100644 --- a/source/cl/test/UnitCL/source/arm64Regression.cpp +++ b/source/cl/test/UnitCL/source/arm64Regression.cpp @@ -61,21 +61,23 @@ int test_copy(cl_context context, cl_command_queue queue, cl_kernel kernel, cl_int error = 0; // Fill input buffer with random data - void *inData = (void *)malloc(global_buffer_size); + void *inData = malloc(global_buffer_size); generateRandomData(inData, global_buffer_size, generator); buffers[0] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, global_buffer_size, inData, &error); EXPECT_SUCCESS(error); - void *outData = (void *)malloc(global_buffer_size); + void *outData = malloc(global_buffer_size); buffers[1] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, global_buffer_size, outData, &error); EXPECT_SUCCESS(error); - error = clSetKernelArg(kernel, 0, sizeof(buffers[0]), &buffers[0]); + error = clSetKernelArg(kernel, 0, sizeof(buffers[0]), + static_cast(&buffers[0])); EXPECT_SUCCESS(error); - error = clSetKernelArg(kernel, 1, sizeof(buffers[1]), &buffers[1]); + error = clSetKernelArg(kernel, 1, sizeof(buffers[1]), + static_cast(&buffers[1])); EXPECT_SUCCESS(error); error = clSetKernelArg(kernel, 2, local_buffer_size, NULL); EXPECT_SUCCESS(error); diff --git a/source/cl/test/UnitCL/source/clBuildProgram.cpp b/source/cl/test/UnitCL/source/clBuildProgram.cpp index e942aeb81..91baf9f88 100644 --- a/source/cl/test/UnitCL/source/clBuildProgram.cpp +++ b/source/cl/test/UnitCL/source/clBuildProgram.cpp @@ -447,7 +447,8 @@ TEST_F(clBuildProgramMacroTest, NotDefined) { cl_int status; kernel = clCreateKernel(program, "foo", &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯o_value)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯o_value))); cl_event taskEvent; ASSERT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -467,7 +468,8 @@ TEST_F(clBuildProgramMacroTest, DefaultDefined) { cl_int status; kernel = clCreateKernel(program, "foo", &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯o_value)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯o_value))); cl_event taskEvent; ASSERT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -484,7 +486,8 @@ TEST_F(clBuildProgramMacroTest, ValueDefined) { cl_int status; kernel = clCreateKernel(program, "foo", &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯o_value)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯o_value))); cl_event taskEvent; ASSERT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -501,7 +504,8 @@ TEST_F(clBuildProgramMacroTest, ValueDefinedThenSpace) { cl_int status; kernel = clCreateKernel(program, "foo", &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯o_value)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯o_value))); cl_event taskEvent; ASSERT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -550,7 +554,8 @@ class clBuildProgramTwiceTest : public ucl::CommandQueueTest { cl_int status; kernel = clCreateKernel(program, "foo", &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯o_value)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯o_value))); cl_event taskEvent; ASSERT_SUCCESS( clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); diff --git a/source/cl/test/UnitCL/source/clCloneKernel.cpp b/source/cl/test/UnitCL/source/clCloneKernel.cpp index 71cba321e..bfe98e9ce 100644 --- a/source/cl/test/UnitCL/source/clCloneKernel.cpp +++ b/source/cl/test/UnitCL/source/clCloneKernel.cpp @@ -87,7 +87,8 @@ TEST_F(clCloneKernelTest, SuccessWithArgs) { UCL::cl::buffer buffer; ASSERT_SUCCESS( buffer.create(context, CL_MEM_READ_WRITE, sizeof(cl_int) * 64, nullptr)); - ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), + static_cast(&buffer))); cl_int error; clone_kernel = clCloneKernel(source_kernel, &error); ASSERT_SUCCESS(error); @@ -136,7 +137,8 @@ TEST_F(clCloneKernelRunTest, Default) { clone_kernel = clCloneKernel(source_kernel, &error); // Set an argument on clone_kernel, run it, then validate. ASSERT_SUCCESS(error); - ASSERT_SUCCESS(clSetKernelArg(clone_kernel, 0, sizeof(buffer), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(clone_kernel, 0, sizeof(buffer), + static_cast(&buffer))); cl_event ndRangeEvent; ASSERT_SUCCESS(clEnqueueNDRangeKernel(command_queue, clone_kernel, 1, nullptr, &work_size, nullptr, 0, nullptr, @@ -159,7 +161,8 @@ TEST_F(clCloneKernelRunTest, Default) { TEST_F(clCloneKernelRunTest, WithArgs) { // Set an argument on the source_kernel, run it, then validate. - ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), + static_cast(&buffer))); cl_event ndRangeSourceEvent; ASSERT_SUCCESS(clEnqueueNDRangeKernel(command_queue, source_kernel, 1, nullptr, &work_size, nullptr, 0, @@ -200,7 +203,8 @@ TEST_F(clCloneKernelRunTest, WithArgs) { TEST_F(clCloneKernelRunTest, WithChangedArgs) { // Set an argument on the source_kernel, run it, then validate. - ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), + static_cast(&buffer))); cl_event ndRangeSourceEvent; ASSERT_SUCCESS(clEnqueueNDRangeKernel(command_queue, source_kernel, 1, nullptr, &work_size, nullptr, 0, @@ -241,7 +245,8 @@ TEST_F(clCloneKernelRunTest, WithChangedArgs) { TEST_F(clCloneKernelRunTest, ParallelWithChangedArgs) { // Set an argument on the source_kernel. - ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(source_kernel, 0, sizeof(buffer), + static_cast(&buffer))); // Clone source_kernel. cl_int error; clone_kernel = clCloneKernel(source_kernel, &error); diff --git a/source/cl/test/UnitCL/source/clCompileProgram.cpp b/source/cl/test/UnitCL/source/clCompileProgram.cpp index d45b8c167..04b551c5a 100644 --- a/source/cl/test/UnitCL/source/clCompileProgram.cpp +++ b/source/cl/test/UnitCL/source/clCompileProgram.cpp @@ -522,7 +522,8 @@ TEST_F(clCompileProgramMacroTest, NotDefined) { EXPECT_SUCCESS(status); kernel = clCreateKernel(linkedProgram, "foo", &status); EXPECT_SUCCESS(status); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯oValue)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯oValue))); cl_event taskEvent; EXPECT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -547,7 +548,8 @@ TEST_F(clCompileProgramMacroTest, DefaultDefined) { EXPECT_SUCCESS(status); kernel = clCreateKernel(linkedProgram, "foo", &status); EXPECT_SUCCESS(status); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯oValue)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯oValue))); cl_event taskEvent; EXPECT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; @@ -572,7 +574,8 @@ TEST_F(clCompileProgramMacroTest, ValueDefined) { EXPECT_SUCCESS(status); kernel = clCreateKernel(linkedProgram, "foo", &status); EXPECT_SUCCESS(status); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), ¯oValue)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(¯oValue))); cl_event taskEvent; EXPECT_SUCCESS(clEnqueueTask(command_queue, kernel, 0, nullptr, &taskEvent)); cl_int value; diff --git a/source/cl/test/UnitCL/source/clCreateBuffer.cpp b/source/cl/test/UnitCL/source/clCreateBuffer.cpp index d0c8d32ac..f8cefc348 100644 --- a/source/cl/test/UnitCL/source/clCreateBuffer.cpp +++ b/source/cl/test/UnitCL/source/clCreateBuffer.cpp @@ -295,12 +295,12 @@ class clCreateBufferHostPtr : public ucl::CommandQueueTest { EXPECT_TRUE(cl_buf_C); UCL_SUCCESS_OR_RETURN_ERR(errorcode); - UCL_SUCCESS_OR_RETURN_ERR( - clSetKernelArg(kernel, 0, sizeof(cl_buf_A), &cl_buf_A)); - UCL_SUCCESS_OR_RETURN_ERR( - clSetKernelArg(kernel, 1, sizeof(cl_buf_B), &cl_buf_B)); - UCL_SUCCESS_OR_RETURN_ERR( - clSetKernelArg(kernel, 2, sizeof(cl_buf_C), &cl_buf_C)); + UCL_SUCCESS_OR_RETURN_ERR(clSetKernelArg(kernel, 0, sizeof(cl_buf_A), + static_cast(&cl_buf_A))); + UCL_SUCCESS_OR_RETURN_ERR(clSetKernelArg(kernel, 1, sizeof(cl_buf_B), + static_cast(&cl_buf_B))); + UCL_SUCCESS_OR_RETURN_ERR(clSetKernelArg(kernel, 2, sizeof(cl_buf_C), + static_cast(&cl_buf_C))); UCL_SUCCESS_OR_RETURN_ERR( clEnqueueNDRangeKernel(command_queue, kernel, 1, nullptr, &elements, diff --git a/source/cl/test/UnitCL/source/clCreateCommandQueue.cpp b/source/cl/test/UnitCL/source/clCreateCommandQueue.cpp index c9456a893..7d674922b 100644 --- a/source/cl/test/UnitCL/source/clCreateCommandQueue.cpp +++ b/source/cl/test/UnitCL/source/clCreateCommandQueue.cpp @@ -50,8 +50,7 @@ TEST_F(clCreateCommandQueueTest, WithBadProperties) { cl_int errcode; const auto all_valid_properties = static_cast( CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE); - const auto properties = - static_cast(~all_valid_properties); + const auto properties = ~all_valid_properties; EXPECT_FALSE(clCreateCommandQueue(context, device, properties, &errcode)); ASSERT_EQ_ERRCODE(CL_INVALID_VALUE, errcode); } diff --git a/source/cl/test/UnitCL/source/clCreateImage.cpp b/source/cl/test/UnitCL/source/clCreateImage.cpp index d0b3938c9..dbd9b0fe2 100644 --- a/source/cl/test/UnitCL/source/clCreateImage.cpp +++ b/source/cl/test/UnitCL/source/clCreateImage.cpp @@ -106,9 +106,9 @@ TEST_F(clCreateImageTest, InvalidImageDesc) { ASSERT_EQ_ERRCODE(CL_INVALID_IMAGE_DESCRIPTOR, errorcode); } -cl_mem imageSizeTest(cl_context context, cl_mem_object_type type, size_t width, - size_t height, size_t depth, size_t arraySize, - cl_mem buffer, cl_int *error) { +static cl_mem imageSizeTest(cl_context context, cl_mem_object_type type, + size_t width, size_t height, size_t depth, + size_t arraySize, cl_mem buffer, cl_int *error) { cl_image_format format; format.image_channel_data_type = CL_FLOAT; format.image_channel_order = CL_RGBA; diff --git a/source/cl/test/UnitCL/source/clCreateProgramWithBinary.cpp b/source/cl/test/UnitCL/source/clCreateProgramWithBinary.cpp index e27c03f98..ad63d2d26 100644 --- a/source/cl/test/UnitCL/source/clCreateProgramWithBinary.cpp +++ b/source/cl/test/UnitCL/source/clCreateProgramWithBinary.cpp @@ -48,7 +48,8 @@ class clCreateProgramWithBinaryTest : public ucl::ContextTest { binaries[i] = new unsigned char[binaryLengths[i]]; } ASSERT_SUCCESS(clGetProgramInfo(originalProgram, CL_PROGRAM_BINARIES, - binaryLengthsSize, binaries, nullptr)); + binaryLengthsSize, + static_cast(binaries), nullptr)); binaryStatii.resize(1); ASSERT_SUCCESS(clReleaseProgram(originalProgram)); } @@ -217,8 +218,10 @@ TEST_F(clCreateProgramWithBinaryTest, DefaultNDRangeKernel) { EXPECT_TRUE(kernel); ASSERT_SUCCESS(errcode); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufin)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &bufout)); + ASSERT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&bufin))); + ASSERT_SUCCESS( + clSetKernelArg(kernel, 1, sizeof(cl_mem), static_cast(&bufout))); cl_command_queue command_q = clCreateCommandQueue(context, device, 0, &errcode); @@ -285,8 +288,10 @@ TEST_F(clCreateProgramWithBinaryTest, ConcurrentNDRangeKernel) { EXPECT_TRUE(kernel); ASSERT_SUCCESS(errcode); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufin)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &bufout)); + ASSERT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&bufin))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&bufout))); cl_command_queue command_q = clCreateCommandQueue(context, device, 0, &errcode); diff --git a/source/cl/test/UnitCL/source/clCreateProgramWithBuiltInKernels.cpp b/source/cl/test/UnitCL/source/clCreateProgramWithBuiltInKernels.cpp index 47952ba1d..903505295 100644 --- a/source/cl/test/UnitCL/source/clCreateProgramWithBuiltInKernels.cpp +++ b/source/cl/test/UnitCL/source/clCreateProgramWithBuiltInKernels.cpp @@ -57,7 +57,8 @@ TEST_F(clCreateProgramWithBuiltInKernelsTest, BadBuiltinKernelNames) { TEST_F(clCreateProgramWithBuiltInKernelsTest, BadDeviceInDevices) { enum { NUM_BAD_DEVICES = 2 }; cl_device_id fakeDevices[NUM_BAD_DEVICES]; - std::memset(fakeDevices, 0, sizeof(cl_device_id) * NUM_BAD_DEVICES); + std::memset(static_cast(fakeDevices), 0, + sizeof(cl_device_id) * NUM_BAD_DEVICES); cl_int status = !CL_SUCCESS; ASSERT_FALSE(clCreateProgramWithBuiltInKernels(context, NUM_BAD_DEVICES, diff --git a/source/cl/test/UnitCL/source/clCreateSampler.cpp b/source/cl/test/UnitCL/source/clCreateSampler.cpp index 1011a78e4..8daaaf409 100644 --- a/source/cl/test/UnitCL/source/clCreateSampler.cpp +++ b/source/cl/test/UnitCL/source/clCreateSampler.cpp @@ -28,7 +28,7 @@ struct sampler_params { cl_filter_mode filter_mode; }; -std::ostream &operator<<(std::ostream &out, sampler_params params) { +static std::ostream &operator<<(std::ostream &out, sampler_params params) { const std::string normalized_coords = params.normalized_coords ? "CL_TRUE" : "CL_FALSE"; out << "sampler_params{" diff --git a/source/cl/test/UnitCL/source/clEnqueueCopyImage.cpp b/source/cl/test/UnitCL/source/clEnqueueCopyImage.cpp index ac5539435..6b9171574 100644 --- a/source/cl/test/UnitCL/source/clEnqueueCopyImage.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueCopyImage.cpp @@ -52,7 +52,7 @@ struct clEnqueueCopyImageParamTest cl_event event = nullptr; }; -void generate_data(UCL::vector &data) { +static void generate_data(UCL::vector &data) { std::mt19937 range; range.seed(); // Using a larger than necessary distribution integer type because @@ -140,9 +140,9 @@ TEST_P(clEnqueueCopyImageParamTest, Default1D2D) { ASSERT_SUCCESS(clEnqueueReadImage(command_queue, dst_image, CL_TRUE, read_origin, read_region, 0, 0, out.data(), 1, &event, nullptr)); - const size_t region_begin = pixel_size * dst_origin[0] + - pixel_size * desc2d.image_width * dst_origin[1]; - const size_t region_end = region_begin + pixel_size * region[0] * region[1]; + const size_t region_begin = (pixel_size * dst_origin[0]) + + (pixel_size * desc2d.image_width * dst_origin[1]); + const size_t region_end = region_begin + (pixel_size * region[0] * region[1]); for (size_t i = 0; i < out.size(); ++i) { if (i >= region_begin && i < region_end) { ASSERT_EQ(in[i - region_begin], out[i]); @@ -196,11 +196,11 @@ TEST_P(clEnqueueCopyImageParamTest, Default1D3D) { read_origin, read_region, 0, 0, out.data(), 1, &event, nullptr)); const size_t region_begin = - pixel_size * dst_origin[0] + - pixel_size * desc3d.image_width * dst_origin[1] + - pixel_size * desc3d.image_width * desc3d.image_height * dst_origin[2]; + (pixel_size * dst_origin[0]) + + (pixel_size * desc3d.image_width * dst_origin[1]) + + (pixel_size * desc3d.image_width * desc3d.image_height * dst_origin[2]); const size_t region_end = - region_begin + pixel_size * region[0] * region[1] * region[2]; + region_begin + (pixel_size * region[0] * region[1] * region[2]); for (size_t i = 0; i < out.size(); ++i) { if (i >= region_begin && i < region_end) { ASSERT_EQ(in[i - region_begin], out[i]); @@ -256,10 +256,10 @@ TEST_P(clEnqueueCopyImageParamTest, Default1D2DArray) { read_origin, read_region, 0, 0, out.data(), 1, &event, nullptr)); const size_t region_begin = - pixel_size * dst_origin[0] + - pixel_size * desc2darray.image_width * dst_origin[1] + - pixel_size * desc2darray.image_width * desc2darray.image_height * - dst_origin[2]; + (pixel_size * dst_origin[0]) + + (pixel_size * desc2darray.image_width * dst_origin[1]) + + (pixel_size * desc2darray.image_width * desc2darray.image_height * + dst_origin[2]); const size_t region_end = pixel_size * region[0] * region[1] * region[2]; for (size_t i = 0; i < out.size(); ++i) { if (i >= region_begin && i < region_end) { diff --git a/source/cl/test/UnitCL/source/clEnqueueFillBuffer.cpp b/source/cl/test/UnitCL/source/clEnqueueFillBuffer.cpp index 2bf578a67..7f449e259 100644 --- a/source/cl/test/UnitCL/source/clEnqueueFillBuffer.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueFillBuffer.cpp @@ -106,7 +106,7 @@ TEST_F(clEnqueueFillBufferTest, OffsetSizeRangeOutOfBounds) { ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, clEnqueueFillBuffer(command_queue, buffer, &pattern, pattern_size, - size / 2 + 1, size / 2, 0, nullptr, nullptr)); + (size / 2) + 1, size / 2, 0, nullptr, nullptr)); } TEST_F(clEnqueueFillBufferTest, NullPattern) { diff --git a/source/cl/test/UnitCL/source/clEnqueueFillImage.cpp b/source/cl/test/UnitCL/source/clEnqueueFillImage.cpp index 9870b6c12..0299c1509 100644 --- a/source/cl/test/UnitCL/source/clEnqueueFillImage.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueFillImage.cpp @@ -51,7 +51,7 @@ struct clEnqueueFillImageTest for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uint4 element = {{index, index + 1, index + 2, index + 3}}; original[index] = element; } @@ -169,7 +169,7 @@ TEST_P(clEnqueueFillImageTest, FillFull) { : DIMENSION_LENGTH; z < zMax; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const ucl::UInt4 result(mappedImage[index]); const ucl::UInt4 compare(fillColor); ASSERT_EQ(compare, result) << "Coordinates (" << x << ", " << y << ", " @@ -234,7 +234,7 @@ TEST_P(clEnqueueFillImageTest, FillStart) { (z < HALF_DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const ucl::UInt4 result(mappedImage[index]); const ucl::UInt4 compare((inRegion) ? fillColor : original[index]); ASSERT_EQ(result, compare) << "Coordinates (" << x << ", " << y << ", " @@ -304,7 +304,7 @@ TEST_P(clEnqueueFillImageTest, FillEnd) { ((HALF_DIMENSION_LENGTH <= z) && (z < DIMENSION_LENGTH))); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const ucl::UInt4 result(mappedImage[index]); const ucl::UInt4 expect((inRegion) ? fillColor : original[index]); ASSERT_EQ(expect, result) << "Coordinates (" << x << ", " << y << ", " @@ -378,7 +378,7 @@ TEST_P(clEnqueueFillImageTest, FillMiddle) { (z < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH))); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const ucl::UInt4 result(mappedImage[index]); const ucl::UInt4 expect((inRegion) ? fillColor : original[index]); ASSERT_EQ(expect, result) << "Coordinates (" << x << ", " << y << ", " diff --git a/source/cl/test/UnitCL/source/clEnqueueMapBuffer.cpp b/source/cl/test/UnitCL/source/clEnqueueMapBuffer.cpp index f6aa294c9..6833e9513 100644 --- a/source/cl/test/UnitCL/source/clEnqueueMapBuffer.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueMapBuffer.cpp @@ -555,9 +555,8 @@ TEST_F(clEnqueueMapBufferTest, InvalidValueFlags) { const auto all_valid_map_flags = static_cast( CL_MAP_READ | CL_MAP_WRITE | CL_MAP_WRITE_INVALIDATE_REGION); void *const map = - clEnqueueMapBuffer(command_queue, inMem, CL_FALSE, - static_cast(~all_valid_map_flags), 0, - int_size, 1, &writeEvent, &mapEvent, &errcode); + clEnqueueMapBuffer(command_queue, inMem, CL_FALSE, (~all_valid_map_flags), + 0, int_size, 1, &writeEvent, &mapEvent, &errcode); EXPECT_EQ_ERRCODE(CL_INVALID_VALUE, errcode); EXPECT_FALSE(map); } @@ -771,7 +770,8 @@ kernel void generate(global uint* ptr) { ASSERT_SUCCESS(error); // Write the test data into subBuffer. - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &subBuffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&subBuffer))); cl_event ndRangeEvent; ASSERT_SUCCESS(clEnqueueNDRangeKernel(command_queue, kernel, 1, nullptr, &numElementsPerRegion, nullptr, 0, @@ -811,7 +811,7 @@ kernel void generate(global uint* ptr) { ASSERT_EQ(42 + index, output[index + numElementsPerRegion]); } for (size_t index = 0; index < numElementsPerRegion; index++) { - ASSERT_EQ(0, output[index + numElementsPerRegion * 2]); + ASSERT_EQ(0, output[index + (numElementsPerRegion * 2)]); } } diff --git a/source/cl/test/UnitCL/source/clEnqueueMapImage.cpp b/source/cl/test/UnitCL/source/clEnqueueMapImage.cpp index 58bb1d160..d77510496 100644 --- a/source/cl/test/UnitCL/source/clEnqueueMapImage.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueMapImage.cpp @@ -59,8 +59,8 @@ struct clEnqueueMapImageTestsParams { bool is_pitched; }; -std::ostream &operator<<(std::ostream &out, - const clEnqueueMapImageTestsParams ¶ms) { +static std::ostream &operator<<(std::ostream &out, + const clEnqueueMapImageTestsParams ¶ms) { out << "clEnqueueMapImageTestsParams{.object_type{"; switch (params.object_type) { #define CASE(TYPE) \ @@ -319,8 +319,8 @@ TEST_P(clEnqueueMapImageTests, MapImage) { // arbitrary, but is used to try and force it down different paths wrt the // host_ptr const size_t good_alignment = 4096; - UCL::vector srcPixels((size_t)numPixels * 4 + 1); - UCL::vector dstPixels((size_t)numPixels * 4 + 1); + UCL::vector srcPixels((numPixels * 4) + 1); + UCL::vector dstPixels((numPixels * 4) + 1); float *src_pixels = srcPixels.data(); float *dst_pixels = dstPixels.data(); @@ -350,8 +350,10 @@ TEST_P(clEnqueueMapImageTests, MapImage) { ASSERT_SUCCESS(error); ASSERT_NE(nullptr, src_image); ASSERT_NE(nullptr, dst_image); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_image), &src_image)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_image), &dst_image)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_image), + static_cast(&src_image))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_image), + static_cast(&dst_image))); size_t image_row_pitch = 0; size_t image_slice_pitch = 0; @@ -387,16 +389,16 @@ TEST_P(clEnqueueMapImageTests, MapImage) { for (size_t row = 0; row < image_desc.image_height; row++) { for (size_t col = 0; col < image_desc.image_width; col++) { const size_t src_pixel_index = - slice * slice_pitch_in_pixels + row * row_pitch_in_pixels + col; + (slice * slice_pitch_in_pixels) + (row * row_pitch_in_pixels) + col; const size_t dst_pixel_index = - slice * (image_desc.image_width * image_desc.image_height) + - row * image_desc.image_height + col; + (slice * (image_desc.image_width * image_desc.image_height)) + + (row * image_desc.image_height) + col; for (size_t element = 0; element < 4; element++) { - ASSERT_EQ(src_pixels[src_pixel_index * 4 + element], - dst_pixels[dst_pixel_index * 4 + element]) + ASSERT_EQ(src_pixels[(src_pixel_index * 4) + element], + dst_pixels[(dst_pixel_index * 4) + element]) << "At pixel : " << dst_pixel_index << '\n' - << src_pixels[src_pixel_index * 4 + element] << " vs " - << dst_pixels[dst_pixel_index * 4 + element] << '\n' + << src_pixels[(src_pixel_index * 4) + element] << " vs " + << dst_pixels[(dst_pixel_index * 4) + element] << '\n' << "Total : " << numPixels; } } diff --git a/source/cl/test/UnitCL/source/clEnqueueNDRangeKernel.cpp b/source/cl/test/UnitCL/source/clEnqueueNDRangeKernel.cpp index 618928e5d..d0986065b 100644 --- a/source/cl/test/UnitCL/source/clEnqueueNDRangeKernel.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueNDRangeKernel.cpp @@ -601,7 +601,7 @@ TEST_F(clEnqueueNDRangeKernelTest, ConcurrentBuildDefines) { clBuildProgram(program, 0, nullptr, define.c_str(), nullptr, nullptr); cl_mem buf = clCreateBuffer(ctx, 0, sizeof(cl_int), nullptr, nullptr); cl_kernel kernel = clCreateKernel(program, "k", nullptr); - clSetKernelArg(kernel, 0, sizeof(cl_mem), &buf); + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&buf)); clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &range, nullptr, 0, nullptr, nullptr); cl_int result = -1; @@ -751,7 +751,7 @@ TEST_F(clEnqueueNDRangeKernelTest, NoDeadlockDueToInternalEventCaching) { // of a command group itself waiting on the earlier command group's signal. ASSERT_EQ(CL_SUCCESS, clSetEventCallback(event, CL_COMPLETE, possible_deadlock_callback, - &callback_wait_event)); + static_cast(&callback_wait_event))); event = nullptr; // Fourth command and member of the third command group. @@ -1447,7 +1447,8 @@ struct NDRangeValue { } }; -std::ostream &operator<<(std::ostream &out, const NDRangeValue &nd_range) { +static std::ostream &operator<<(std::ostream &out, + const NDRangeValue &nd_range) { out << "NDRangeValue{"; out << ".work dimensions{" << nd_range.work_dim << "}"; out << ".global work offset{"; @@ -1999,8 +2000,10 @@ struct clEnqueueNDRangeImageTest nullptr, &error); ASSERT_SUCCESS(error); ASSERT_NE(nullptr, dst_image); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_image), &src_image)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_image), &dst_image)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_image), + static_cast(&src_image))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_image), + static_cast(&dst_image))); } void TearDown() override { @@ -2252,8 +2255,8 @@ class LinearIDTest EXPECT_TRUE(output_buffer); ASSERT_SUCCESS(error_code); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 0, sizeof(output_buffer), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(output_buffer), + static_cast(&output_buffer))); ASSERT_SUCCESS(clEnqueueNDRangeKernel( command_queue, kernel, work_dim, global_work_offset.data(), @@ -2391,8 +2394,8 @@ TEST_F(GetEnqueuedLocalSizeTest, Uniform1D) { nullptr, &error_code); EXPECT_TRUE(output_buffer); ASSERT_SUCCESS(error_code); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 0, sizeof(output_buffer), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(output_buffer), + static_cast(&output_buffer))); cl_event kernel_event; ASSERT_SUCCESS(clEnqueueNDRangeKernel( @@ -2438,8 +2441,8 @@ TEST_F(GetEnqueuedLocalSizeTest, Uniform2D) { nullptr, &error_code); EXPECT_TRUE(output_buffer); ASSERT_SUCCESS(error_code); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 0, sizeof(output_buffer), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(output_buffer), + static_cast(&output_buffer))); cl_event kernel_event; ASSERT_SUCCESS(clEnqueueNDRangeKernel( @@ -2487,8 +2490,8 @@ TEST_F(GetEnqueuedLocalSizeTest, Uniform3D) { EXPECT_TRUE(output_buffer); ASSERT_SUCCESS(error_code); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 0, sizeof(output_buffer), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(output_buffer), + static_cast(&output_buffer))); cl_event kernel_event; ASSERT_SUCCESS(clEnqueueNDRangeKernel( diff --git a/source/cl/test/UnitCL/source/clEnqueueNativeKernel.cpp b/source/cl/test/UnitCL/source/clEnqueueNativeKernel.cpp index 3d3072aca..429cadf71 100644 --- a/source/cl/test/UnitCL/source/clEnqueueNativeKernel.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueNativeKernel.cpp @@ -17,7 +17,7 @@ #include "Common.h" #include "EventWaitList.h" -void CL_CALLBACK user_func(void *args) { +static void CL_CALLBACK user_func(void *args) { // Redmine #5130: do stuff (void)args; } diff --git a/source/cl/test/UnitCL/source/clEnqueueReadBufferRect.cpp b/source/cl/test/UnitCL/source/clEnqueueReadBufferRect.cpp index a86b207ef..077b5ef8c 100644 --- a/source/cl/test/UnitCL/source/clEnqueueReadBufferRect.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueReadBufferRect.cpp @@ -42,7 +42,7 @@ class clEnqueueReadBufferRectTest : public ucl::CommandQueueTest, for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); payload[index] = static_cast(index); scratch[index] = INITIAL_SCRATCH; } @@ -90,14 +90,14 @@ TEST_F(clEnqueueReadBufferRectTest, ReadFull2D) { for (unsigned int x = 0; x < DIMENSION_LENGTH; x++) { for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(payload[index], scratch[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -124,14 +124,14 @@ TEST_F(clEnqueueReadBufferRectTest, ReadStart2D) { for (unsigned int x = 0; x < HALF_DIMENSION_LENGTH; x++) { for (unsigned int y = 0; y < HALF_DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(payload[index], scratch[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -143,7 +143,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadStart2D) { for (unsigned int y = HALF_DIMENSION_LENGTH; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -174,7 +174,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadEnd2D) { for (unsigned int y = 0; y < HALF_DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -184,14 +184,14 @@ TEST_F(clEnqueueReadBufferRectTest, ReadEnd2D) { for (unsigned int x = HALF_DIMENSION_LENGTH; x < DIMENSION_LENGTH; x++) { for (unsigned int y = HALF_DIMENSION_LENGTH; y < DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(payload[index], scratch[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -222,7 +222,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadMiddle2D) { for (unsigned int y = 0; y < QUARTER_DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -234,14 +234,14 @@ TEST_F(clEnqueueReadBufferRectTest, ReadMiddle2D) { x < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH; x++) { for (unsigned int y = QUARTER_DIMENSION_LENGTH; y < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(payload[index], scratch[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -255,7 +255,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadMiddle2D) { y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_SCRATCH, scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -278,7 +278,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadFull3D) { for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(payload[index], scratch[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -311,7 +311,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadStart3D) { (z < HALF_DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compareValue = (inRegion) ? payload[index] : INITIAL_SCRATCH; ASSERT_EQ(compareValue, scratch[index]) @@ -349,7 +349,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadEnd3D) { (HALF_DIMENSION_LENGTH <= z) && (z < DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compareValue = (inRegion) ? payload[index] : INITIAL_SCRATCH; ASSERT_EQ(compareValue, scratch[index]) @@ -392,7 +392,7 @@ TEST_F(clEnqueueReadBufferRectTest, ReadMiddle3D) { (z < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compareValue = (inRegion) ? payload[index] : INITIAL_SCRATCH; ASSERT_EQ(compareValue, scratch[index]) @@ -695,7 +695,7 @@ TEST_F(clEnqueueReadBufferRectTest, const size_t region[DIMENSIONS] = {DIMENSION_LENGTH, DIMENSION_LENGTH, DIMENSION_LENGTH}; - const size_t invalidSlicePitch = DIMENSION_LENGTH * DIMENSION_LENGTH + 1; + const size_t invalidSlicePitch = (DIMENSION_LENGTH * DIMENSION_LENGTH) + 1; ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, @@ -741,7 +741,7 @@ TEST_F(clEnqueueReadBufferRectTest, const size_t region[DIMENSIONS] = {DIMENSION_LENGTH, DIMENSION_LENGTH, DIMENSION_LENGTH}; - const size_t invalidSlicePitch = DIMENSION_LENGTH * DIMENSION_LENGTH + 1; + const size_t invalidSlicePitch = (DIMENSION_LENGTH * DIMENSION_LENGTH) + 1; ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, diff --git a/source/cl/test/UnitCL/source/clEnqueueReadImage.cpp b/source/cl/test/UnitCL/source/clEnqueueReadImage.cpp index 2a837b273..d5e5881e1 100644 --- a/source/cl/test/UnitCL/source/clEnqueueReadImage.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueReadImage.cpp @@ -42,7 +42,7 @@ struct clEnqueueReadImageTestBase : ucl::CommandQueueTest, for (size_t x = 0; x < width; ++x) { for (size_t y = 0; y < height; ++y) { for (size_t z = 0; z < depth; ++z) { - const size_t i = x + width * y + width * height * z; + const size_t i = x + (width * y) + (width * height * z); image_data[i].s[0] = static_cast(x); image_data[i].s[1] = static_cast(y); image_data[i].s[2] = static_cast(z); @@ -106,10 +106,11 @@ TEST_F(clEnqueueReadImage2DTest, DefaultWriteRegionReadWholeImage) { // Verify for (size_t h = 0; h < height; ++h) { for (size_t w = 0; w < width; ++w) { - printf("{%u, %u, %u, %u}\t", - // w + width * h, - result_data[w + width * h].s[0], result_data[w + width * h].s[1], - result_data[w + width * h].s[2], result_data[w + width * h].s[3]); + printf( + "{%u, %u, %u, %u}\t", + // w + width * h, + result_data[w + (width * h)].s[0], result_data[w + (width * h)].s[1], + result_data[w + (width * h)].s[2], result_data[w + (width * h)].s[3]); } printf("\n"); } @@ -140,10 +141,10 @@ TEST_F(clEnqueueReadImage2DTest, DefaultReadRegion) { for (size_t w = 0; w < read_region[1]; ++w) { printf("{%u, %u, %u, %u}\t", // w + read_region[0] * h, - result_data[w + read_region[0] * h].s[0], - result_data[w + read_region[0] * h].s[1], - result_data[w + read_region[0] * h].s[2], - result_data[w + read_region[0] * h].s[3]); + result_data[w + (read_region[0] * h)].s[0], + result_data[w + (read_region[0] * h)].s[1], + result_data[w + (read_region[0] * h)].s[2], + result_data[w + (read_region[0] * h)].s[3]); } printf("\n"); } @@ -164,7 +165,7 @@ TEST_F(clEnqueueReadImage3DTest, DefaultReadWholeImage) { for (size_t x = 0; x < width; ++x) { for (size_t y = 0; y < height; ++y) { for (size_t z = 0; z < depth; ++z) { - const size_t i = x + width * y + width * height * z; + const size_t i = x + (width * y) + (width * height * z); for (int j = 0; j < 4; ++j) { ASSERT_EQ(image_data[i].s[j], result_data[i].s[j]) << "image_data and result_data differ at: " diff --git a/source/cl/test/UnitCL/source/clEnqueueTask.cpp b/source/cl/test/UnitCL/source/clEnqueueTask.cpp index 2ad291e3b..be6c53ee4 100644 --- a/source/cl/test/UnitCL/source/clEnqueueTask.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueTask.cpp @@ -82,14 +82,16 @@ class clEnqueueTaskTest : public ucl::CommandQueueTest, TestWithEventWaitList { ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_mem)); + clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_mem))); cl_mem output_mem = clCreateBuffer(context, CL_MEM_WRITE_ONLY, buffer_size, nullptr, &status); EXPECT_TRUE(output_mem); ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_mem)); + clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_mem))); ASSERT_EQ_ERRCODE( err, clEnqueueTask(command_queue, kernel, num_events, events, event)); @@ -134,14 +136,16 @@ TEST_F(clEnqueueTaskTest, DefaultNoEventWaitList) { ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_mem)); + clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_mem))); cl_mem output_mem = clCreateBuffer(context, CL_MEM_WRITE_ONLY, buffer_size, nullptr, &status); EXPECT_TRUE(output_mem); ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_mem)); + clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_mem))); cl_event event; EXPECT_EQ_ERRCODE(CL_SUCCESS, clEnqueueTask(command_queue, kernel, 0, nullptr, &event)); @@ -164,14 +168,16 @@ TEST_F(clEnqueueTaskTest, DefaultWithEventWaitList) { ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_mem)); + clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_mem))); cl_mem output_mem = clCreateBuffer(context, CL_MEM_WRITE_ONLY, buffer_size, nullptr, &status); EXPECT_TRUE(output_mem); ASSERT_SUCCESS(status); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_mem)); + clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_mem))); cl_int pattern = 0; cl_event fill_event; EXPECT_EQ_ERRCODE( @@ -206,8 +212,8 @@ TEST_F(clEnqueueTaskTest, TaskExecutesExactlyOnce) { EXPECT_TRUE(buffer); ASSERT_SUCCESS(status); - EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &buffer)); + EXPECT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&buffer))); EXPECT_EQ_ERRCODE( CL_SUCCESS, diff --git a/source/cl/test/UnitCL/source/clEnqueueWriteBufferRect.cpp b/source/cl/test/UnitCL/source/clEnqueueWriteBufferRect.cpp index aec233da5..0f7545271 100644 --- a/source/cl/test/UnitCL/source/clEnqueueWriteBufferRect.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueWriteBufferRect.cpp @@ -45,7 +45,7 @@ class clEnqueueWriteBufferRectTest : public ucl::CommandQueueTest, for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); write_data[index] = static_cast(index); buffer_data[index] = INITIAL_BUFFER_DATA; } @@ -393,14 +393,14 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteFull2D) { for (unsigned int x = 0; x < DIMENSION_LENGTH; x++) { for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(buffer_data[index], write_data[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -440,14 +440,14 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteStart2D) { for (unsigned int x = 0; x < HALF_DIMENSION_LENGTH; x++) { for (unsigned int y = 0; y < HALF_DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(buffer_data[index], write_data[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -459,7 +459,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteStart2D) { for (unsigned int y = HALF_DIMENSION_LENGTH; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -503,7 +503,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteMiddle2D) { for (unsigned int y = 0; y < QUARTER_DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -515,14 +515,14 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteMiddle2D) { x < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH; x++) { for (unsigned int y = QUARTER_DIMENSION_LENGTH; y < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(buffer_data[index], write_data[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -536,7 +536,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteMiddle2D) { y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -581,7 +581,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteEnd2D) { for (unsigned int y = 0; y < HALF_DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -591,14 +591,14 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteEnd2D) { for (unsigned int x = HALF_DIMENSION_LENGTH; x < DIMENSION_LENGTH; x++) { for (unsigned int y = HALF_DIMENSION_LENGTH; y < DIMENSION_LENGTH; y++) { - const unsigned int index = x + DIMENSION_LENGTH * y; + const unsigned int index = x + (DIMENSION_LENGTH * y); ASSERT_EQ(buffer_data[index], write_data[index]) << "Coordinates (" << x << ", " << y << ", 0) linearized to (" << index << ")"; for (unsigned int z = 1; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(INITIAL_BUFFER_DATA, buffer_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -635,7 +635,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteFull3D) { for (unsigned int y = 0; y < DIMENSION_LENGTH; y++) { for (unsigned int z = 0; z < DIMENSION_LENGTH; z++) { const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); ASSERT_EQ(buffer_data[index], write_data[index]) << "Coordinates (" << x << ", " << y << ", " << z << ") linearized to (" << index << ")"; @@ -682,7 +682,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteStart3D) { (z < HALF_DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compare_value = (in_region) ? buffer_data[index] : INITIAL_BUFFER_DATA; ASSERT_EQ(compare_value, buffer_data[index]) @@ -734,7 +734,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteEnd3D) { (HALF_DIMENSION_LENGTH <= z) && (z < DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compare_value = (in_region) ? buffer_data[index] : INITIAL_BUFFER_DATA; ASSERT_EQ(compare_value, buffer_data[index]) @@ -791,7 +791,7 @@ TEST_F(clEnqueueWriteBufferRectTest, WriteMiddle3D) { (z < QUARTER_DIMENSION_LENGTH + HALF_DIMENSION_LENGTH); const unsigned int index = - x + DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z); + x + (DIMENSION_LENGTH * (y + DIMENSION_LENGTH * z)); const cl_uchar compare_value = (in_region) ? buffer_data[index] : INITIAL_BUFFER_DATA; ASSERT_EQ(compare_value, buffer_data[index]) diff --git a/source/cl/test/UnitCL/source/clEnqueueWriteImage.cpp b/source/cl/test/UnitCL/source/clEnqueueWriteImage.cpp index e1771246b..bccf51dbc 100644 --- a/source/cl/test/UnitCL/source/clEnqueueWriteImage.cpp +++ b/source/cl/test/UnitCL/source/clEnqueueWriteImage.cpp @@ -283,7 +283,7 @@ class clEnqueueWriteImageTestBase : public ucl::CommandQueueTest { for (size_t x = 0; x < width; ++x) { for (size_t y = 0; y < region_y; ++y) { for (size_t z = 0; z < region_z; ++z) { - const size_t i = x + width * y + width * region_y * z; + const size_t i = x + (width * y) + (width * region_y * z); // Appease compiler warnings about subscript above array bounds. assert(i < num_pixels); if (i < num_pixels) { @@ -384,7 +384,7 @@ struct clEnqueueWriteImageVerify cl_mem image = nullptr; }; -void generate_write_data(UCL::vector &data) { +static void generate_write_data(UCL::vector &data) { std::mt19937 range; range.seed(); // Using a larger than necessary distribution integer type because diff --git a/source/cl/test/UnitCL/source/clFlush.cpp b/source/cl/test/UnitCL/source/clFlush.cpp index 848d44abf..46f51196b 100644 --- a/source/cl/test/UnitCL/source/clFlush.cpp +++ b/source/cl/test/UnitCL/source/clFlush.cpp @@ -168,7 +168,7 @@ TEST_F(clFlushTest, ConcurrentFlushFinish) { // threads at once. This is very similar to clSetEventCallback.EnqueueCallback // but it also calls clFlush within the callback as these were two separate // deadlocks. -void CL_CALLBACK EnqueueFlushCallback(cl_event, cl_int, void *s) { +static void CL_CALLBACK EnqueueFlushCallback(cl_event, cl_int, void *s) { auto state = static_cast *>(s); const size_t range = 1; ASSERT_SUCCESS(clEnqueueNDRangeKernel(state->first, state->second, 1, nullptr, diff --git a/source/cl/test/UnitCL/source/clGetCommandQueueInfo.cpp b/source/cl/test/UnitCL/source/clGetCommandQueueInfo.cpp index 4d0eb22e7..9ed24bcad 100644 --- a/source/cl/test/UnitCL/source/clGetCommandQueueInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetCommandQueueInfo.cpp @@ -67,7 +67,8 @@ TEST_F(clGetCommandQueueInfoTest, QueueContext) { ASSERT_EQ(sizeof(cl_context), size); cl_context queueContext = nullptr; ASSERT_SUCCESS(clGetCommandQueueInfo(queue, CL_QUEUE_CONTEXT, size, - &queueContext, nullptr)); + static_cast(&queueContext), + nullptr)); ASSERT_EQ(context, queueContext); } @@ -78,7 +79,8 @@ TEST_F(clGetCommandQueueInfoTest, QueueDevice) { ASSERT_EQ(sizeof(cl_device_id), size); cl_device_id queueDevice = nullptr; ASSERT_SUCCESS(clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, size, - &queueDevice, nullptr)); + static_cast(&queueDevice), + nullptr)); ASSERT_EQ(device, queueDevice); } @@ -187,9 +189,9 @@ TEST_F(clGetCommandQueueInfoTest, QueueDeviceDefaultSuccess) { clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_command_queue), size); cl_command_queue commandQueue; - ASSERT_SUCCESS(clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT, - sizeof(commandQueue), &commandQueue, - nullptr)); + ASSERT_SUCCESS(clGetCommandQueueInfo( + queue, CL_QUEUE_DEVICE_DEFAULT, sizeof(commandQueue), + static_cast(&commandQueue), nullptr)); } TEST_F(clGetCommandQueueInfoTest, QueueDeviceDeviceInvalidValue) { @@ -200,6 +202,7 @@ TEST_F(clGetCommandQueueInfoTest, QueueDeviceDeviceInvalidValue) { ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT, - sizeof(commandQueue) - 1, &commandQueue, nullptr)); + sizeof(commandQueue) - 1, + static_cast(&commandQueue), nullptr)); } #endif diff --git a/source/cl/test/UnitCL/source/clGetContextInfo.cpp b/source/cl/test/UnitCL/source/clGetContextInfo.cpp index f42750bcd..a6e262d0e 100644 --- a/source/cl/test/UnitCL/source/clGetContextInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetContextInfo.cpp @@ -87,8 +87,8 @@ TEST_F(clGetContextInfoTest, ContextDevicesDefault) { UCL::Buffer devices(size / sizeof(cl_device_id)); - EXPECT_SUCCESS( - clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, nullptr)); + EXPECT_SUCCESS(clGetContextInfo(context, CL_CONTEXT_DEVICES, size, + static_cast(devices), nullptr)); bool foundAllDevices = true; for (unsigned int i = 0; i < devices.size(); i++) { @@ -107,9 +107,9 @@ TEST_F(clGetContextInfoTest, ContextDevicesDefault) { TEST_F(clGetContextInfoTest, BadContextDeviceSize) { cl_device_id device = nullptr; - EXPECT_EQ_ERRCODE( - CL_INVALID_VALUE, - clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, &device, nullptr)); + EXPECT_EQ_ERRCODE(CL_INVALID_VALUE, + clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, + static_cast(&device), nullptr)); ASSERT_FALSE(device); } diff --git a/source/cl/test/UnitCL/source/clGetDeviceInfo.cpp b/source/cl/test/UnitCL/source/clGetDeviceInfo.cpp index a69ac4efc..738a8a154 100644 --- a/source/cl/test/UnitCL/source/clGetDeviceInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetDeviceInfo.cpp @@ -972,7 +972,7 @@ TEST_F(clGetDeviceInfoTest, PARENT_DEVICE) { ASSERT_EQ(sizeof(cl_device_id), size); cl_device_id payload; ASSERT_SUCCESS(clGetDeviceInfo(device, CL_DEVICE_PARENT_DEVICE, size, - &payload, nullptr)); + static_cast(&payload), nullptr)); ASSERT_EQ(0, payload); // assume we are a parent device } @@ -1040,7 +1040,7 @@ TEST_F(clGetDeviceInfoTest, PARTITION_TYPE) { UCL::Buffer payload( size / sizeof(cl_device_partition_property)); ASSERT_SUCCESS(clGetDeviceInfo(device, CL_DEVICE_PARTITION_TYPE, size, - payload, nullptr)); + static_cast(payload), nullptr)); ASSERT_EQ(1u, payload.size()); ASSERT_EQ(0u, payload[0]); // we are not a sub-device } @@ -1053,8 +1053,8 @@ TEST_F(clGetDeviceInfoTest, PLATFORM) { ASSERT_EQ(sizeof(cl_platform_id), size); cl_platform_id payload; - ASSERT_SUCCESS( - clGetDeviceInfo(device, CL_DEVICE_PLATFORM, size, &payload, nullptr)); + ASSERT_SUCCESS(clGetDeviceInfo(device, CL_DEVICE_PLATFORM, size, + static_cast(&payload), nullptr)); ASSERT_EQ(platform, payload); // assume we don't support any partition types } diff --git a/source/cl/test/UnitCL/source/clGetEventInfo.cpp b/source/cl/test/UnitCL/source/clGetEventInfo.cpp index 483d31acd..2b201bef4 100644 --- a/source/cl/test/UnitCL/source/clGetEventInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetEventInfo.cpp @@ -92,7 +92,8 @@ class clGetEventInfoTest : public ucl::CommandQueueTest { assert(sizeof(T) == size_needed); T result; - errcode = clGetEventInfo(event, param_name, size_needed, &result, nullptr); + errcode = clGetEventInfo(event, param_name, size_needed, + static_cast(&result), nullptr); EXPECT_SUCCESS(errcode); if (expected != result) { EXPECT_EQ(expected, result); @@ -352,7 +353,8 @@ TEST_F(clGetEventInfoTest, EnqueueTaskEvent) { cl_mem out = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(cl_int), nullptr, &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &out)); + ASSERT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&out))); cl_int a = 7; ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_int), &a)); cl_int b = 6; @@ -545,7 +547,7 @@ TEST_F(clGetEventInfoTest, CopyBufferRect) { ASSERT_SUCCESS(clReleaseMemObject(out_mem)); } -void CL_CALLBACK user_fun(void *args) { (void)args; } +static void CL_CALLBACK user_fun(void *args) { (void)args; } TEST_F(clGetEventInfoTest, NativeKernel) { struct Args { diff --git a/source/cl/test/UnitCL/source/clGetImageInfo.cpp b/source/cl/test/UnitCL/source/clGetImageInfo.cpp index e3a5df913..f767d26ac 100644 --- a/source/cl/test/UnitCL/source/clGetImageInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetImageInfo.cpp @@ -323,8 +323,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer1D) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(nullptr, imageBuffer); } @@ -494,8 +494,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer1DBuffer) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(buffer, imageBuffer); } @@ -665,8 +665,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer1DArray) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(nullptr, imageBuffer); } @@ -836,8 +836,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer2D) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(nullptr, imageBuffer); } @@ -1008,8 +1008,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer2DArray) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(nullptr, imageBuffer); } @@ -1180,8 +1180,8 @@ TEST_P(clGetImageInfoParamTest, DefaultBuffer3D) { ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_mem), size); cl_mem imageBuffer; - ASSERT_SUCCESS( - clGetImageInfo(image, CL_IMAGE_BUFFER, size, &imageBuffer, nullptr)); + ASSERT_SUCCESS(clGetImageInfo(image, CL_IMAGE_BUFFER, size, + static_cast(&imageBuffer), nullptr)); ASSERT_EQ(nullptr, imageBuffer); } @@ -1457,7 +1457,7 @@ TEST_F(clGetImageInfoTest, InvalidValueParamValueSize) { cl_mem bufferValue; ASSERT_EQ_ERRCODE(CL_INVALID_VALUE, clGetImageInfo(image, CL_IMAGE_BUFFER, sizeof(cl_mem) - 1, - &bufferValue, nullptr)); + static_cast(&bufferValue), nullptr)); cl_uint numValue; ASSERT_EQ_ERRCODE(CL_INVALID_VALUE, clGetImageInfo(image, CL_IMAGE_NUM_MIP_LEVELS, diff --git a/source/cl/test/UnitCL/source/clGetKernelArgInfo.cpp b/source/cl/test/UnitCL/source/clGetKernelArgInfo.cpp index 96b014ede..1f5c0640d 100644 --- a/source/cl/test/UnitCL/source/clGetKernelArgInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetKernelArgInfo.cpp @@ -29,7 +29,8 @@ void sourceToBinaryKernel(cl_device_id device, cl_context context, std::vector binary(size); std::array binaries{{binary.data()}}; ASSERT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, - binaries.data(), nullptr)); + static_cast(binaries.data()), + nullptr)); cl_int binary_status; cl_int status; binary_program = clCreateProgramWithBinary( @@ -196,7 +197,7 @@ struct TypeNameParam { const char *expected; }; -std::ostream &operator<<(std::ostream &out, const TypeNameParam ¶m) { +static std::ostream &operator<<(std::ostream &out, const TypeNameParam ¶m) { out << "TypeNameParam{.input{\"" << param.input << "\"}, .expected{\"" << param.expected << "\"}}"; return out; @@ -460,7 +461,7 @@ TEST_P(clGetKernelArgInfoTypeQualifierTest, Default) { } } -type_qual_pair typeQualParams[] = { +static type_qual_pair typeQualParams[] = { type_qual_pair(CL_KERNEL_ARG_TYPE_NONE, ""), type_qual_pair(CL_KERNEL_ARG_TYPE_CONST, "const"), type_qual_pair(CL_KERNEL_ARG_TYPE_VOLATILE, "volatile"), @@ -527,7 +528,7 @@ TEST_P(clGetKernelArgInfoConstTypeQualifierTest, Default) { } } -type_qual_pair typeConstQualParams[] = { +static type_qual_pair typeConstQualParams[] = { type_qual_pair(CL_KERNEL_ARG_TYPE_RESTRICT, "restrict"), }; diff --git a/source/cl/test/UnitCL/source/clGetKernelInfo.cpp b/source/cl/test/UnitCL/source/clGetKernelInfo.cpp index f7f1baccb..ab642ce10 100644 --- a/source/cl/test/UnitCL/source/clGetKernelInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetKernelInfo.cpp @@ -139,7 +139,7 @@ TEST_F(clGetKernelInfoTest, KernelContext) { ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_context), size); ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, size, - &kernelContext, nullptr)); + static_cast(&kernelContext), nullptr)); ASSERT_EQ(context, kernelContext); } @@ -149,7 +149,7 @@ TEST_F(clGetKernelInfoTest, KernelProgram) { ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_PROGRAM, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_program), size); ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_PROGRAM, size, - &kernelProgram, nullptr)); + static_cast(&kernelProgram), nullptr)); ASSERT_EQ(program, kernelProgram); } @@ -255,7 +255,7 @@ TEST_F(clGetKernelInfoTwoKernelsTest, KernelContext) { ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_context), size); ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, size, - &kernelContext, nullptr)); + static_cast(&kernelContext), nullptr)); ASSERT_EQ(context, kernelContext); } @@ -265,7 +265,7 @@ TEST_F(clGetKernelInfoTwoKernelsTest, KernelProgram) { ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_PROGRAM, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_program), size); ASSERT_SUCCESS(clGetKernelInfo(kernel, CL_KERNEL_PROGRAM, size, - &kernelProgram, nullptr)); + static_cast(&kernelProgram), nullptr)); ASSERT_EQ(program, kernelProgram); } @@ -340,7 +340,7 @@ TEST_P(clGetKernelInfoAttributeTest, Default) { } } -InputPair AttributeParams[] = { +static InputPair AttributeParams[] = { { "void kernel " "__attribute__((reqd_work_group_size(1, 1, 1)))" diff --git a/source/cl/test/UnitCL/source/clGetMemObjectInfo.cpp b/source/cl/test/UnitCL/source/clGetMemObjectInfo.cpp index c4c7f9b5a..02888b0ed 100644 --- a/source/cl/test/UnitCL/source/clGetMemObjectInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetMemObjectInfo.cpp @@ -102,8 +102,8 @@ TEST_F(clGetMemObjectInfoTest, MemHostPtr) { clGetMemObjectInfo(hostBuffer, CL_MEM_HOST_PTR, 0, nullptr, &size)); ASSERT_EQ(sizeof(void *), size); void *ptr = nullptr; - ASSERT_SUCCESS( - clGetMemObjectInfo(hostBuffer, CL_MEM_HOST_PTR, size, &ptr, nullptr)); + ASSERT_SUCCESS(clGetMemObjectInfo(hostBuffer, CL_MEM_HOST_PTR, size, + static_cast(&ptr), nullptr)); ASSERT_EQ(&data, ptr); ASSERT_SUCCESS(clReleaseMemObject(hostBuffer)); @@ -116,8 +116,8 @@ TEST_F(clGetMemObjectInfoTest, MemHostPtr) { ASSERT_SUCCESS( clGetMemObjectInfo(devBuffer, CL_MEM_HOST_PTR, 0, nullptr, &size)); ASSERT_EQ(sizeof(void *), size); - ASSERT_SUCCESS( - clGetMemObjectInfo(devBuffer, CL_MEM_HOST_PTR, size, &ptr, nullptr)); + ASSERT_SUCCESS(clGetMemObjectInfo(devBuffer, CL_MEM_HOST_PTR, size, + static_cast(&ptr), nullptr)); ASSERT_FALSE(ptr); ASSERT_SUCCESS(clReleaseMemObject(devBuffer)); @@ -151,8 +151,9 @@ TEST_F(clGetMemObjectInfoTest, MemContext) { ASSERT_SUCCESS(clGetMemObjectInfo(buffer, CL_MEM_CONTEXT, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_context), size); cl_context thisContext = (cl_context)1; - ASSERT_SUCCESS( - clGetMemObjectInfo(buffer, CL_MEM_CONTEXT, size, &thisContext, nullptr)); + ASSERT_SUCCESS(clGetMemObjectInfo(buffer, CL_MEM_CONTEXT, size, + static_cast(&thisContext), + nullptr)); ASSERT_EQ(context, thisContext); ASSERT_SUCCESS(clReleaseMemObject(buffer)); @@ -169,7 +170,8 @@ TEST_F(clGetMemObjectInfoTest, MemAssociateMemObject) { ASSERT_EQ(sizeof(cl_mem), size); cl_mem otherBuffer = (cl_mem)1; ASSERT_SUCCESS(clGetMemObjectInfo(buffer, CL_MEM_ASSOCIATED_MEMOBJECT, size, - &otherBuffer, nullptr)); + static_cast(&otherBuffer), + nullptr)); ASSERT_FALSE(otherBuffer); ASSERT_SUCCESS(clReleaseMemObject(buffer)); @@ -201,7 +203,8 @@ TEST_F(clGetMemObjectInfoTest, MemAssociateMemObjectWithSubBuffer) { ASSERT_EQ(sizeof(cl_mem), size); cl_mem otherBuffer = nullptr; ASSERT_SUCCESS(clGetMemObjectInfo(subBuffer, CL_MEM_ASSOCIATED_MEMOBJECT, - size, &otherBuffer, nullptr)); + size, static_cast(&otherBuffer), + nullptr)); ASSERT_EQ(buffer, otherBuffer); ASSERT_SUCCESS(clReleaseMemObject(subBuffer)); diff --git a/source/cl/test/UnitCL/source/clGetProgramBuildInfo.cpp b/source/cl/test/UnitCL/source/clGetProgramBuildInfo.cpp index ae0c3291d..692e761c0 100644 --- a/source/cl/test/UnitCL/source/clGetProgramBuildInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetProgramBuildInfo.cpp @@ -101,9 +101,9 @@ TEST_F(clGetProgramBuildInfoGoodTest, ProgramBuildStatusBinarySuccess) { const auto *program_binary = new unsigned char[binary_size]; - EXPECT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, - sizeof(unsigned char *), &program_binary, - nullptr)); + EXPECT_SUCCESS( + clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char *), + static_cast(&program_binary), nullptr)); cl_int binary_status = CL_INVALID_BINARY; cl_int error = CL_INVALID_BINARY; diff --git a/source/cl/test/UnitCL/source/clGetProgramInfo.cpp b/source/cl/test/UnitCL/source/clGetProgramInfo.cpp index 897de4f37..65b0a6122 100644 --- a/source/cl/test/UnitCL/source/clGetProgramInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetProgramInfo.cpp @@ -104,7 +104,7 @@ TEST_F(clGetProgramInfoTest, ProgramContextDefault) { ASSERT_EQ(sizeof(cl_context), size); cl_context thisContext = nullptr; ASSERT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_CONTEXT, size, - &thisContext, nullptr)); + static_cast(&thisContext), nullptr)); ASSERT_EQ(context, thisContext); } @@ -112,7 +112,8 @@ TEST_F(clGetProgramInfoTest, ProgramContextBadParamValue) { cl_context thisContext = nullptr; ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, - clGetProgramInfo(program, CL_PROGRAM_CONTEXT, 0, &thisContext, nullptr)); + clGetProgramInfo(program, CL_PROGRAM_CONTEXT, 0, + static_cast(&thisContext), nullptr)); } TEST_F(clGetProgramInfoTest, ProgramNumDevicesDefault) { @@ -139,8 +140,8 @@ TEST_F(clGetProgramInfoTest, ProgramDevicesDefault) { clGetProgramInfo(program, CL_PROGRAM_DEVICES, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_device_id), size); UCL::Buffer devices(size / sizeof(cl_device_id)); - ASSERT_SUCCESS( - clGetProgramInfo(program, CL_PROGRAM_DEVICES, size, devices, nullptr)); + ASSERT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_DEVICES, size, + static_cast(devices), nullptr)); for (unsigned int i = 0; i < devices.size(); i++) { ASSERT_TRUE(devices[0]); } @@ -152,9 +153,9 @@ TEST_F(clGetProgramInfoTest, ProgramDevicesBadParamValue) { clGetProgramInfo(program, CL_PROGRAM_DEVICES, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_device_id), size); UCL::Buffer devices(size / sizeof(cl_device_id)); - ASSERT_EQ_ERRCODE( - CL_INVALID_VALUE, - clGetProgramInfo(program, CL_PROGRAM_DEVICES, 0, devices, nullptr)); + ASSERT_EQ_ERRCODE(CL_INVALID_VALUE, + clGetProgramInfo(program, CL_PROGRAM_DEVICES, 0, + static_cast(devices), nullptr)); } TEST_F(clGetProgramInfoProgramSourceTest, ProgramSourceDefault) { @@ -234,8 +235,8 @@ TEST_F(clGetProgramInfoTest, ProgramBinariesDefault) { binaries[i] = new unsigned char[binarySizes[i]]; } - EXPECT_SUCCESS( - clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, binaries, nullptr)); + EXPECT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, + static_cast(binaries), nullptr)); for (size_t i = 0; i < binaries.size(); ++i) { delete[] binaries[i]; @@ -247,9 +248,9 @@ TEST_F(clGetProgramInfoTest, ProgramBinaraiesBadParamValue) { ASSERT_SUCCESS( clGetProgramInfo(program, CL_PROGRAM_BINARIES, 0, nullptr, &size)); UCL::Buffer binaries(size); - EXPECT_EQ_ERRCODE( - CL_INVALID_VALUE, - clGetProgramInfo(program, CL_PROGRAM_BINARIES, 0, binaries, nullptr)); + EXPECT_EQ_ERRCODE(CL_INVALID_VALUE, + clGetProgramInfo(program, CL_PROGRAM_BINARIES, 0, + static_cast(binaries), nullptr)); } TEST_F(clGetProgramInfoProgramSourceTest, ProgramBinariesDefault) { @@ -275,8 +276,8 @@ TEST_F(clGetProgramInfoProgramSourceTest, ProgramBinariesDefault) { binaries[i] = nullptr; } - EXPECT_SUCCESS( - clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, binaries, nullptr)); + EXPECT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, + static_cast(binaries), nullptr)); } TEST_F(clGetProgramInfoTest, ProgramBinariesParamValueSizeRet) { @@ -466,10 +467,11 @@ TEST_F(clGetProgramInfoInvalidProgramTest, ProgramInfo) { binaries[i] = storage[i].data(); } - ASSERT_EQ_ERRCODE(CL_INVALID_PROGRAM, - clGetProgramInfo(program, CL_PROGRAM_BINARIES, - num_devices * sizeof(unsigned char *), - binaries.data(), nullptr)); + ASSERT_EQ_ERRCODE( + CL_INVALID_PROGRAM, + clGetProgramInfo(program, CL_PROGRAM_BINARIES, + num_devices * sizeof(unsigned char *), + static_cast(binaries.data()), nullptr)); } struct clGetProgramInfoBuiltinTest : ucl::ContextTest { @@ -556,7 +558,8 @@ TEST_F(clGetProgramInfoBuiltinTest, Binary) { // clCreateProgramWithBuiltInKernels, so while no binaries exist this is // still expected to succeed. ASSERT_SUCCESS(clGetProgramInfo(program, CL_PROGRAM_BINARIES, size, - binaries.data(), nullptr)); + static_cast(binaries.data()), + nullptr)); } TEST_F(clGetProgramInfoBuiltinTest, Source) { diff --git a/source/cl/test/UnitCL/source/clGetSamplerInfo.cpp b/source/cl/test/UnitCL/source/clGetSamplerInfo.cpp index d1667ea11..675ec31fb 100644 --- a/source/cl/test/UnitCL/source/clGetSamplerInfo.cpp +++ b/source/cl/test/UnitCL/source/clGetSamplerInfo.cpp @@ -57,7 +57,7 @@ TEST_F(clGetSamplerInfoTest, InvalidValueParamValueSize) { ASSERT_EQ_ERRCODE( CL_INVALID_VALUE, clGetSamplerInfo(sampler, CL_SAMPLER_CONTEXT, sizeof(cl_context) - 1, - &sampler_context, nullptr)); + static_cast(&sampler_context), nullptr)); cl_bool normalized_coords; ASSERT_EQ_ERRCODE( @@ -83,7 +83,7 @@ TEST_F(clGetSamplerInfoTest, InvalidSampler) { ASSERT_EQ_ERRCODE( CL_INVALID_SAMPLER, clGetSamplerInfo(nullptr, CL_SAMPLER_CONTEXT, sizeof(cl_context), - &sampler_context, nullptr)); + static_cast(&sampler_context), nullptr)); } TEST_F(clGetSamplerInfoTest, DefaultReferenceCount) { @@ -94,9 +94,9 @@ TEST_F(clGetSamplerInfoTest, DefaultReferenceCount) { TEST_F(clGetSamplerInfoTest, DefaultContext) { cl_context sampler_context; - ASSERT_SUCCESS(clGetSamplerInfo(sampler, CL_SAMPLER_CONTEXT, - sizeof(cl_context), &sampler_context, - nullptr)); + ASSERT_SUCCESS( + clGetSamplerInfo(sampler, CL_SAMPLER_CONTEXT, sizeof(cl_context), + static_cast(&sampler_context), nullptr)); ASSERT_EQ(context, sampler_context); } @@ -112,7 +112,7 @@ struct sampler_args { cl_filter_mode filter_mode; }; -std::ostream &operator<<(std::ostream &out, sampler_args params) { +static std::ostream &operator<<(std::ostream &out, sampler_args params) { const std::string normalized_coords = params.normalized_coords ? "CL_TRUE" : "CL_FALSE"; out << "sampler_args{" diff --git a/source/cl/test/UnitCL/source/clGetSupportedImageFormats.cpp b/source/cl/test/UnitCL/source/clGetSupportedImageFormats.cpp index 600d71294..b149cb398 100644 --- a/source/cl/test/UnitCL/source/clGetSupportedImageFormats.cpp +++ b/source/cl/test/UnitCL/source/clGetSupportedImageFormats.cpp @@ -28,23 +28,8 @@ class clGetSupportedImageFormatsTest : public ucl::ContextTest { } }; -cl_int getImageFormatsHelper(cl_context context, cl_mem_flags flags, - cl_mem_object_type type, - UCL::vector &formats) { - cl_uint numEntries = 0; - cl_int error = - clGetSupportedImageFormats(context, flags, type, 0, nullptr, &numEntries); - if (error) { - return error; - } - formats.resize(numEntries); - error = clGetSupportedImageFormats(context, flags, type, numEntries, - formats.data(), nullptr); - return error; -} - -void printImageFormats(cl_mem_object_type type, - UCL::vector &formats) { +static void printImageFormats(cl_mem_object_type type, + UCL::vector &formats) { #define CASE(TYPE) \ case TYPE: \ (void)printf(#TYPE " "); \ diff --git a/source/cl/test/UnitCL/source/clReleaseEvent.cpp b/source/cl/test/UnitCL/source/clReleaseEvent.cpp index ac0c4736f..6902e9cfa 100644 --- a/source/cl/test/UnitCL/source/clReleaseEvent.cpp +++ b/source/cl/test/UnitCL/source/clReleaseEvent.cpp @@ -88,10 +88,12 @@ class clReleaseEventWithQueueTest : public ucl::ContextTest { input.data(), &err); streams[1] = clCreateBuffer( context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, n, nullptr, &err); - err = clSetKernelArg(kernel, 0, sizeof(streams[0]), &streams[0]); + err = clSetKernelArg(kernel, 0, sizeof(streams[0]), + static_cast(&streams[0])); EXPECT_SUCCESS(err); - err = clSetKernelArg(kernel, 1, sizeof(streams[1]), &streams[1]); + err = clSetKernelArg(kernel, 1, sizeof(streams[1]), + static_cast(&streams[1])); EXPECT_SUCCESS(err); err = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &n, nullptr, 0, diff --git a/source/cl/test/UnitCL/source/clSetEventCallback.cpp b/source/cl/test/UnitCL/source/clSetEventCallback.cpp index 6583f690d..472e6475a 100644 --- a/source/cl/test/UnitCL/source/clSetEventCallback.cpp +++ b/source/cl/test/UnitCL/source/clSetEventCallback.cpp @@ -50,8 +50,8 @@ TEST_F(clSetEventCallbackTest, Default) { }; cl_event hit = nullptr; - ASSERT_SUCCESS( - clSetEventCallback(event, CL_COMPLETE, Callback::callback, &hit)); + ASSERT_SUCCESS(clSetEventCallback(event, CL_COMPLETE, Callback::callback, + static_cast(&hit))); ASSERT_SUCCESS(clSetUserEventStatus(event, CL_COMPLETE)); @@ -230,8 +230,8 @@ TEST_F(clSetEventCallbackTest, Recursive) { }; cl_event hit = nullptr; - ASSERT_SUCCESS( - clSetEventCallback(event, CL_COMPLETE, Callback::callbackDirect, &hit)); + ASSERT_SUCCESS(clSetEventCallback( + event, CL_COMPLETE, Callback::callbackDirect, static_cast(&hit))); ASSERT_SUCCESS(clSetUserEventStatus(event, CL_COMPLETE)); @@ -262,8 +262,8 @@ TEST_F(clSetEventCallbackTest, RecursiveForReachedStatus) { ASSERT_SUCCESS(clSetUserEventStatus(event, CL_COMPLETE)); cl_event hit = nullptr; - ASSERT_SUCCESS( - clSetEventCallback(event, CL_COMPLETE, Callback::callbackDirect, &hit)); + ASSERT_SUCCESS(clSetEventCallback( + event, CL_COMPLETE, Callback::callbackDirect, static_cast(&hit))); // We assume that `clSetUserEventStatus` immediately triggers the callback. // That is very likely for most OpenCL implementations but not necessary. @@ -291,7 +291,8 @@ TEST_F(clSetEventCallbackTest, RecursiveDuringEventRelease) { cl_event hit = nullptr; ASSERT_SUCCESS(clSetEventCallback(event_to_release, CL_COMPLETE, - Callback::callbackDirect, &hit)); + Callback::callbackDirect, + static_cast(&hit))); ASSERT_SUCCESS(clReleaseEvent(event_to_release)); diff --git a/source/cl/test/UnitCL/source/clSetMemObjectDestructorCallback.cpp b/source/cl/test/UnitCL/source/clSetMemObjectDestructorCallback.cpp index 01bc20ce3..170f3cd7e 100644 --- a/source/cl/test/UnitCL/source/clSetMemObjectDestructorCallback.cpp +++ b/source/cl/test/UnitCL/source/clSetMemObjectDestructorCallback.cpp @@ -37,8 +37,8 @@ TEST_F(clSetMemObjectDestructorCallbackTest, Default) { }; cl_mem hit = nullptr; - ASSERT_SUCCESS( - clSetMemObjectDestructorCallback(buffer, Callback::callback, &hit)); + ASSERT_SUCCESS(clSetMemObjectDestructorCallback(buffer, Callback::callback, + static_cast(&hit))); ASSERT_SUCCESS(clReleaseMemObject(buffer)); ASSERT_EQ(hit, buffer); } diff --git a/source/cl/test/UnitCL/source/clSetProgramSpecializationConstant.cpp b/source/cl/test/UnitCL/source/clSetProgramSpecializationConstant.cpp index 18d27005b..1c0f65d78 100644 --- a/source/cl/test/UnitCL/source/clSetProgramSpecializationConstant.cpp +++ b/source/cl/test/UnitCL/source/clSetProgramSpecializationConstant.cpp @@ -176,18 +176,25 @@ struct clSetProgramSpecializationConstantSuccessTest void getResults() { int i = 0; - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &boolBuffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &charBuffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &shortBuffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &intBuffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &longBuffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &floatBuffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&boolBuffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&charBuffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&shortBuffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&intBuffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&longBuffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&floatBuffer))); if (UCL::hasDeviceExtensionSupport(device, "cl_khr_fp64")) { - ASSERT_SUCCESS( - clSetKernelArg(kernel, i++, sizeof(cl_mem), &doubleBuffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&doubleBuffer))); } if (UCL::hasDeviceExtensionSupport(device, "cl_khr_fp16")) { - ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), &halfBuffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, i++, sizeof(cl_mem), + static_cast(&halfBuffer))); } cl_event taskEvent; ASSERT_SUCCESS(clEnqueueTask(commandQueue, kernel, 0, nullptr, &taskEvent)); diff --git a/source/cl/test/UnitCL/source/clSetUserEventStatus.cpp b/source/cl/test/UnitCL/source/clSetUserEventStatus.cpp index e21830c13..5ae8e3c83 100644 --- a/source/cl/test/UnitCL/source/clSetUserEventStatus.cpp +++ b/source/cl/test/UnitCL/source/clSetUserEventStatus.cpp @@ -274,18 +274,18 @@ TEST_F(clSetUserEventStatusInOrderTest, BlockQueueOnUserEventWithCommandEvent) { // Set up the kernel args. EXPECT_SUCCESS(clSetKernelArg(store, 0, sizeof(intermediate_buffer_a), - &intermediate_buffer_a)); + static_cast(&intermediate_buffer_a))); EXPECT_SUCCESS(clSetKernelArg(load_and_store_a, 0, sizeof(intermediate_buffer_a), - &intermediate_buffer_a)); + static_cast(&intermediate_buffer_a))); EXPECT_SUCCESS(clSetKernelArg(load_and_store_a, 1, sizeof(intermediate_buffer_b), - &intermediate_buffer_b)); + static_cast(&intermediate_buffer_b))); EXPECT_SUCCESS(clSetKernelArg(load_and_store_b, 0, sizeof(intermediate_buffer_b), - &intermediate_buffer_b)); - EXPECT_SUCCESS( - clSetKernelArg(load_and_store_b, 1, sizeof(final_buffer), &final_buffer)); + static_cast(&intermediate_buffer_b))); + EXPECT_SUCCESS(clSetKernelArg(load_and_store_b, 1, sizeof(final_buffer), + static_cast(&final_buffer))); // Create a user event which the second kernel enqueue will wait on. cl_event user_event = clCreateUserEvent(context, &error); @@ -417,11 +417,11 @@ TEST_F(clSetUserEventStatusInOrderTest, BlockQueueOnUserEvent) { // Set up the kernel args. EXPECT_SUCCESS(clSetKernelArg(store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); + static_cast(&intermediate_buffer))); EXPECT_SUCCESS(clSetKernelArg(load_and_store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(load_and_store, 1, sizeof(final_buffer), &final_buffer)); + static_cast(&intermediate_buffer))); + EXPECT_SUCCESS(clSetKernelArg(load_and_store, 1, sizeof(final_buffer), + static_cast(&final_buffer))); // Create a user event which the second kernel enqueue will wait on. cl_event user_event = clCreateUserEvent(context, &error); @@ -529,11 +529,11 @@ TEST_F(clSetUserEventStatusInOrderTest, BlockQueueOnTwoUserEvents) { // Set up the kernel args. EXPECT_SUCCESS(clSetKernelArg(store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); + static_cast(&intermediate_buffer))); EXPECT_SUCCESS(clSetKernelArg(load_and_store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(load_and_store, 1, sizeof(final_buffer), &final_buffer)); + static_cast(&intermediate_buffer))); + EXPECT_SUCCESS(clSetKernelArg(load_and_store, 1, sizeof(final_buffer), + static_cast(&final_buffer))); // Create user events which the kernel enqueues will wait on. cl_event user_event_a = clCreateUserEvent(context, &error); @@ -646,11 +646,11 @@ TEST_F(clSetUserEventStatusInOrderTest, BlockQueueOnTwoUserEventsReversed) { // Set up the kernel args. EXPECT_SUCCESS(clSetKernelArg(store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); + static_cast(&intermediate_buffer))); EXPECT_SUCCESS(clSetKernelArg(load_and_store, 0, sizeof(intermediate_buffer), - &intermediate_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(load_and_store, 1, sizeof(final_buffer), &final_buffer)); + static_cast(&intermediate_buffer))); + EXPECT_SUCCESS(clSetKernelArg(load_and_store, 1, sizeof(final_buffer), + static_cast(&final_buffer))); // Create users event which the kernel enqueues will wait on. cl_event user_event_a = clCreateUserEvent(context, &error); diff --git a/source/cl/test/UnitCL/source/cl_codeplay_extra_build_options/cl_codeplay_extra_build_options.cpp b/source/cl/test/UnitCL/source/cl_codeplay_extra_build_options/cl_codeplay_extra_build_options.cpp index 83a683236..aee55cbfc 100644 --- a/source/cl/test/UnitCL/source/cl_codeplay_extra_build_options/cl_codeplay_extra_build_options.cpp +++ b/source/cl/test/UnitCL/source/cl_codeplay_extra_build_options/cl_codeplay_extra_build_options.cpp @@ -96,9 +96,11 @@ TEST_F(cl_codeplay_extra_build_options_BuildFlags, EXPECT_SUCCESS(errorcode); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 0, sizeof(cl_mem), &out_buffer)); + clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&out_buffer))); EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(kernel, 1, sizeof(cl_mem), &in_buffer)); + clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&in_buffer))); cl_command_queue command_queue = clCreateCommandQueue(context, device, 0, &errorcode); diff --git a/source/cl/test/UnitCL/source/cl_codeplay_kernel_exec_info/usm.cpp b/source/cl/test/UnitCL/source/cl_codeplay_kernel_exec_info/usm.cpp index 7afbe18f2..7d4d4ddf4 100644 --- a/source/cl/test/UnitCL/source/cl_codeplay_kernel_exec_info/usm.cpp +++ b/source/cl/test/UnitCL/source/cl_codeplay_kernel_exec_info/usm.cpp @@ -228,16 +228,16 @@ TEST_F(KernelExecInfoCodeplayUSMPtrs, IndirectDevicePointer) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect USM pointers to runtime void *indirect_usm_pointers[1] = {device_ptr}; const cl_int err = clSetKernelExecInfoCODEPLAY( exec_info_kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), - indirect_usm_pointers); + static_cast(indirect_usm_pointers)); ASSERT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -259,16 +259,16 @@ TEST_F(KernelExecInfoCodeplayUSMPtrs, OffsetDevicePointer) { SetInputBuffer(offset_device_ptr); // Set kernel arguments - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass base device USM pointer to runtime as used indirectly void *indirect_usm_pointers[1] = {device_ptr}; const cl_int err = clSetKernelExecInfoCODEPLAY( exec_info_kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), - indirect_usm_pointers); + static_cast(indirect_usm_pointers)); ASSERT_SUCCESS(err); // Run 1-D kernel with a global size of half the number of buffer elements @@ -295,10 +295,10 @@ TEST_F(KernelExecInfoCodeplayUSMPtrs, DeviceAccessFlag) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(exec_info_kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, exec_info_kernel, 1, nullptr, @@ -317,9 +317,9 @@ using KernelExecInfoCodeplayUSMFlags = TEST_P(KernelExecInfoCodeplayUSMFlags, ValidUsage) { const cl_kernel_exec_info_codeplay param_name = GetParam(); if (CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL == param_name) { - const cl_int err = - clSetKernelExecInfoCODEPLAY(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(device_ptr), &device_ptr); + const cl_int err = clSetKernelExecInfoCODEPLAY( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(device_ptr), + static_cast(&device_ptr)); ASSERT_SUCCESS(err); } else { cl_bool flag = CL_FALSE; @@ -342,7 +342,8 @@ TEST_P(KernelExecInfoCodeplayUSMFlags, InvalidUsage) { ASSERT_EQ_ERRCODE(err, CL_INVALID_KERNEL); // Invalid param_value_size - err = clSetKernelExecInfoCODEPLAY(kernel, param_name, 0, &device_ptr); + err = clSetKernelExecInfoCODEPLAY(kernel, param_name, 0, + static_cast(&device_ptr)); ASSERT_EQ_ERRCODE(err, CL_INVALID_VALUE); // Invalid param_value diff --git a/source/cl/test/UnitCL/source/cl_codeplay_wfv/wfv_errors.cpp b/source/cl/test/UnitCL/source/cl_codeplay_wfv/wfv_errors.cpp index e64a06e2c..3a8dff399 100644 --- a/source/cl/test/UnitCL/source/cl_codeplay_wfv/wfv_errors.cpp +++ b/source/cl/test/UnitCL/source/cl_codeplay_wfv/wfv_errors.cpp @@ -103,7 +103,7 @@ TEST_F(cl_codeplay_wfv_Test, InvalidWorkGroupSizeMax) { BuildKernel("__kernel void foo() {}", "foo", "-cl-wfv=never"); auto max_work_group_size = getDeviceMaxWorkGroupSize(); auto max_work_item_size_x = getDeviceMaxWorkItemSizes()[0]; - auto size_y = max_work_group_size / max_work_item_size_x + 1; + auto size_y = (max_work_group_size / max_work_item_size_x) + 1; size_t local_size[] = {max_work_item_size_x, size_y, 1}; ASSERT_EQ(CL_INVALID_WORK_GROUP_SIZE, clGetKernelWFVInfoCODEPLAY(kernel, device, 2, nullptr, local_size, diff --git a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel.cpp b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel.cpp index 098eed726..8c572e953 100644 --- a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel.cpp +++ b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel.cpp @@ -179,7 +179,7 @@ TEST_P(USMSetKernelExecInfoTest, ValidUsage) { EXPECT_SUCCESS( clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *) * indirect_usm_pointers.size(), - indirect_usm_pointers.data())); + static_cast(indirect_usm_pointers.data()))); } else { cl_bool flag = CL_FALSE; EXPECT_SUCCESS( @@ -205,8 +205,9 @@ TEST_P(USMSetKernelExecInfoTest, InvalidUsage) { auto indirect_usm_pointers = allPointers(); // Invalid param_value_size - err = clSetKernelExecInfo(kernel, param_name, 0, - indirect_usm_pointers.data()); + err = + clSetKernelExecInfo(kernel, param_name, 0, + static_cast(indirect_usm_pointers.data())); EXPECT_EQ_ERRCODE(err, CL_INVALID_VALUE); // Invalid param_value @@ -384,7 +385,8 @@ TEST_F(USMVectorAddKernelTest, DeviceInputs) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, device_ptrB)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -402,7 +404,8 @@ TEST_F(USMVectorAddKernelTest, HostInputs) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, host_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, host_ptrB)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -420,7 +423,8 @@ TEST_F(USMVectorAddKernelTest, SharedInputs) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, shared_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, shared_ptrB)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -447,7 +451,8 @@ TEST_F(USMVectorAddKernelTest, MixedInputs) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, ptr.first)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, ptr.second)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -502,7 +507,8 @@ TEST_F(USMVectorAddKernelTest, OffsetHostInput) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, host_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_host_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size equal to half the number of cl_int // elements in the buffer @@ -530,7 +536,8 @@ TEST_F(USMVectorAddKernelTest, OffsetSharedInput) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, shared_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_shared_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size equal to half the number of cl_int // elements in the buffer @@ -554,7 +561,8 @@ TEST_F(USMVectorAddKernelTest, OffsetDeviceInput) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_device_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size equal to half the number of cl_int // elements in the buffer @@ -576,7 +584,8 @@ TEST_F(USMVectorAddKernelTest, OverwriteUSMArg) { void *offset_device_ptr = getPointerOffset(device_ptr, half_bytes); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_device_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Overwrite Pointer arg ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); @@ -601,12 +610,14 @@ TEST_F(USMVectorAddKernelTest, OverwriteCLMemArg) { nullptr)); // Set kernel arguments, index 0 and 2 will be overwritten - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 2, device_ptrB)); // Overwrite args - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); // Run 1-D kernel with a global size equal to half the number of cl_int @@ -623,7 +634,8 @@ TEST_F(USMVectorAddKernelTest, SetArgsWithoutEnqueue) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, device_ptrB)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Release kernel and check USM allocations are still usable ASSERT_SUCCESS(clReleaseKernel(kernel)); @@ -648,12 +660,14 @@ TEST_F(USMVectorAddKernelTest, MultipleKernels) { ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_device_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Set arguments on new kernel ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel2, 0, device_ptrB)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel2, 1, offset_deviceB_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel2, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel2, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run original 1-D kernel with a global size equal to half the number of // cl_int elements in the buffer @@ -685,7 +699,8 @@ TEST_F(USMVectorAddKernelTest, RepeatedEnqueue) { ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, offset_device_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Run 1-D kernel with a global size equal to half the number of cl_int // elements in the buffer @@ -714,7 +729,8 @@ TEST_F(USMVectorAddKernelTest, ClonedKernel) { // Set arguments on original kernel ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, device_ptr)); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, device_ptrB)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &cl_mem_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&cl_mem_buffer))); // Clone kernel, arguments should be copied cl_int err = !CL_SUCCESS; diff --git a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel_exec_info.cpp b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel_exec_info.cpp index 8e3de6d55..95b480eee 100644 --- a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel_exec_info.cpp +++ b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_kernel_exec_info.cpp @@ -392,14 +392,16 @@ TEST_F(USMIndirectAccessTest, IndirectDevicePointer) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect USM pointers to runtime void *indirect_usm_pointers[1] = {device_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -425,14 +427,15 @@ TEST_F(USMIndirectAccessTest, IndirectHostPointer) { SetInputBuffer(host_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, device_ptr)); // Pass indirect USM pointers to runtime void *indirect_usm_pointers[1] = {host_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); ASSERT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -458,14 +461,15 @@ TEST_F(USMIndirectAccessTest, IndirectSharedPointer) { SetInputBuffer(shared_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 1, device_ptr)); // Pass indirect USM pointers to runtime void *indirect_usm_pointers[1] = {shared_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); ASSERT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -502,13 +506,14 @@ TEST_F(USMIndirectAccessTest, IndirectDevicePtrInsideHostPtr) { // Set kernel arguments ASSERT_SUCCESS(clSetKernelArgMemPointerINTEL(kernel, 0, host_ptr)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect USM pointers to runtime void *indirect_usm_pointers[1] = {device_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -534,13 +539,16 @@ TEST_F(USMIndirectAccessTest, IndirectDevicePtrThenHostPtr) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect device USM pointer to runtime void *indirect_usm_pointers[1] = {device_ptr}; cl_int err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -564,7 +572,8 @@ TEST_F(USMIndirectAccessTest, IndirectDevicePtrThenHostPtr) { // of indirect device USM pointer indirect_usm_pointers[0] = {host_ptr}; err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + sizeof(void *), + static_cast(indirect_usm_pointers)); ASSERT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -590,15 +599,17 @@ TEST_F(USMIndirectAccessTest, IndirectDevicePtrAndHostPtr) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass both USM pointers to runtime as used indirectly, but only use one in // each execution void *indirect_usm_pointers[2] = {device_ptr, host_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -640,14 +651,16 @@ TEST_F(USMIndirectAccessTest, OffsetDevicePointer) { SetInputBuffer(offset_device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass base device USM pointer to runtime as used indirectly void *indirect_usm_pointers[1] = {device_ptr}; - const cl_int err = - clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + const cl_int err = clSetKernelExecInfo( + kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of half the number of buffer elements @@ -679,8 +692,10 @@ TEST_F(USMIndirectAccessTest, DeviceAccessFlag) { SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -714,8 +729,10 @@ TEST_F(USMIndirectAccessTest, HostAccessFlag) { SetInputBuffer(host_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -757,8 +774,10 @@ TEST_F(USMIndirectAccessTest, DeviceFlagBeforeAlloc) { SetInputBuffer(deferred_device_alloc); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -805,8 +824,10 @@ TEST_F(USMIndirectAccessTest, HostFlagBeforeAlloc) { SetInputBuffer(deferred_host_alloc); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -846,7 +867,8 @@ TEST_F(USMIndirectAccessTest, DeviceFlagAndExplicitPtr) { // Specify deferred device allocation pointer will be used explicitly void *indirect_usm_pointers[1] = {deferred_device_alloc}; err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Initialize USM allocations to patternA @@ -858,8 +880,10 @@ TEST_F(USMIndirectAccessTest, DeviceFlagAndExplicitPtr) { SetInputBuffer(deferred_device_alloc); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -921,15 +945,18 @@ TEST_F(USMIndirectAccessTest, DisableAllFlags) { // Explicitly set that device_ptr is used indirectly by the kernel. void *indirect_usm_pointers[1] = {device_ptr}; err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, - sizeof(void *), indirect_usm_pointers); + sizeof(void *), + static_cast(indirect_usm_pointers)); EXPECT_SUCCESS(err); // Wrap device USM pointer in a struct SetInputBuffer(device_ptr); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Run 1-D kernel with a global size of 'elements' ASSERT_SUCCESS(clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &elements, @@ -952,15 +979,17 @@ TEST_F(USMMultiIndirectAccessTest, Default) { SetInputBuffer(device_ptrA, device_ptrB); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect USM pointers to runtime std::array indirect_usm_pointers = {device_ptrA, device_ptrB}; const cl_int err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *) * indirect_usm_pointers.size(), - indirect_usm_pointers.data()); + static_cast(indirect_usm_pointers.data())); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' @@ -984,15 +1013,17 @@ TEST_F(USMMultiIndirectAccessTest, BlockingFree) { SetInputBuffer(device_ptrA, device_ptrB); // Set kernel arguments - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&output_buffer))); // Pass indirect USM pointers to runtime std::array indirect_usm_pointers = {device_ptrA, device_ptrB}; const cl_int err = clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(void *) * indirect_usm_pointers.size(), - indirect_usm_pointers.data()); + static_cast(indirect_usm_pointers.data())); EXPECT_SUCCESS(err); // Run 1-D kernel with a global size of 'elements' diff --git a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_cpy.cpp b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_cpy.cpp index 8c84d7d5e..12e19bed0 100644 --- a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_cpy.cpp +++ b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_cpy.cpp @@ -101,51 +101,51 @@ struct USMMemCpyTest : public cl_intel_unified_shared_memory_Test { #define SCALAR_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = 0; \ - constexpr static T pattern1 = 42; \ - constexpr static T pattern2 = 0xA; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = 0; \ + static constexpr T pattern1 = 42; \ + static constexpr T pattern2 = 0xA; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR2_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0}}; \ - constexpr static T pattern1 = {{42, 43}}; \ - constexpr static T pattern2 = {{0xA, 0xB}}; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = {{0, 0}}; \ + static constexpr T pattern1 = {{42, 43}}; \ + static constexpr T pattern2 = {{0xA, 0xB}}; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR4_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0, 0, 0}}; \ - constexpr static T pattern1 = {{42, 43, 44, 45}}; \ - constexpr static T pattern2 = {{0xA, 0xB, 0xC, 0xD}}; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = {{0, 0, 0, 0}}; \ + static constexpr T pattern1 = {{42, 43, 44, 45}}; \ + static constexpr T pattern2 = {{0xA, 0xB, 0xC, 0xD}}; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR8_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0, 0, 0, 0, 0, 0}}; \ - constexpr static T pattern1 = {{42, 43, 44, 45, 46, 47, 48, 49}}; \ - constexpr static T pattern2 = { \ + static constexpr T zero_pattern = {{0, 0, 0, 0, 0, 0, 0}}; \ + static constexpr T pattern1 = {{42, 43, 44, 45, 46, 47, 48, 49}}; \ + static constexpr T pattern2 = { \ {0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11}}; \ - constexpr static const char *as_string = #T; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR16_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = { \ + static constexpr T zero_pattern = { \ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; \ - constexpr static T pattern1 = { \ + static constexpr T pattern1 = { \ {42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57}}; \ - constexpr static T pattern2 = {{0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, \ + static constexpr T pattern2 = {{0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, \ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, \ 0x19}}; \ - constexpr static const char *as_string = #T; \ + static constexpr const char *as_string = #T; \ }; template diff --git a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_fill.cpp b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_fill.cpp index 7f1d6dee1..a3a207909 100644 --- a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_fill.cpp +++ b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_fill.cpp @@ -54,51 +54,51 @@ struct USMMemFillTest : public cl_intel_unified_shared_memory_Test { #define SCALAR_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = 0; \ - constexpr static T pattern1 = 42; \ - constexpr static T pattern2 = 0xA; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = 0; \ + static constexpr T pattern1 = 42; \ + static constexpr T pattern2 = 0xA; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR2_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0}}; \ - constexpr static T pattern1 = {{42, 43}}; \ - constexpr static T pattern2 = {{0xA, 0xB}}; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = {{0, 0}}; \ + static constexpr T pattern1 = {{42, 43}}; \ + static constexpr T pattern2 = {{0xA, 0xB}}; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR4_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0, 0, 0}}; \ - constexpr static T pattern1 = {{42, 43, 44, 45}}; \ - constexpr static T pattern2 = {{0xA, 0xB, 0xC, 0xD}}; \ - constexpr static const char *as_string = #T; \ + static constexpr T zero_pattern = {{0, 0, 0, 0}}; \ + static constexpr T pattern1 = {{42, 43, 44, 45}}; \ + static constexpr T pattern2 = {{0xA, 0xB, 0xC, 0xD}}; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR8_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = {{0, 0, 0, 0, 0, 0, 0}}; \ - constexpr static T pattern1 = {{42, 43, 44, 45, 46, 47, 48, 49}}; \ - constexpr static T pattern2 = { \ + static constexpr T zero_pattern = {{0, 0, 0, 0, 0, 0, 0}}; \ + static constexpr T pattern1 = {{42, 43, 44, 45, 46, 47, 48, 49}}; \ + static constexpr T pattern2 = { \ {0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11}}; \ - constexpr static const char *as_string = #T; \ + static constexpr const char *as_string = #T; \ }; #define VECTOR16_PATTERN(T) \ template <> \ struct test_patterns { \ - constexpr static T zero_pattern = { \ + static constexpr T zero_pattern = { \ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; \ - constexpr static T pattern1 = { \ + static constexpr T pattern1 = { \ {42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57}}; \ - constexpr static T pattern2 = {{0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, \ + static constexpr T pattern2 = {{0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, \ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, \ 0x19}}; \ - constexpr static const char *as_string = #T; \ + static constexpr const char *as_string = #T; \ }; template diff --git a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_info.cpp b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_info.cpp index 210677823..34abfd4e8 100644 --- a/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_info.cpp +++ b/source/cl/test/UnitCL/source/cl_intel_unified_shared_memory/usm_mem_info.cpp @@ -178,7 +178,8 @@ TEST_F(USMMemInfoTest, AllocBasePtr) { err = clGetMemAllocInfoINTEL( context, offset_host_ptr, CL_MEM_ALLOC_BASE_PTR_INTEL, - sizeof(host_alloc_base_addr), &host_alloc_base_addr, nullptr); + sizeof(host_alloc_base_addr), + static_cast(&host_alloc_base_addr), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(host_ptr, host_alloc_base_addr); @@ -196,7 +197,8 @@ TEST_F(USMMemInfoTest, AllocBasePtr) { err = clGetMemAllocInfoINTEL( context, offset_shared_ptr, CL_MEM_ALLOC_BASE_PTR_INTEL, - sizeof(shared_alloc_base_addr), &shared_alloc_base_addr, nullptr); + sizeof(shared_alloc_base_addr), + static_cast(&shared_alloc_base_addr), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(shared_ptr, shared_alloc_base_addr); @@ -207,21 +209,21 @@ TEST_F(USMMemInfoTest, AllocBasePtr) { err = clGetMemAllocInfoINTEL( context, offset_device_ptr, CL_MEM_ALLOC_BASE_PTR_INTEL, - sizeof(alloc_base_addr), &alloc_base_addr, nullptr); + sizeof(alloc_base_addr), static_cast(&alloc_base_addr), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(device_ptr, alloc_base_addr); alloc_base_addr = nullptr; err = clGetMemAllocInfoINTEL(context, user_ptr, CL_MEM_ALLOC_BASE_PTR_INTEL, - sizeof(alloc_base_addr), &alloc_base_addr, - nullptr); + sizeof(alloc_base_addr), + static_cast(&alloc_base_addr), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(NULL, alloc_base_addr); alloc_base_addr = nullptr; err = clGetMemAllocInfoINTEL(context, nullptr, CL_MEM_ALLOC_BASE_PTR_INTEL, - sizeof(alloc_base_addr), &alloc_base_addr, - nullptr); + sizeof(alloc_base_addr), + static_cast(&alloc_base_addr), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(NULL, alloc_base_addr); } @@ -302,7 +304,8 @@ TEST_F(USMMemInfoTest, AllocDevice) { cl_device_id host_alloc_device = device; err = clGetMemAllocInfoINTEL( context, offset_host_ptr, CL_MEM_ALLOC_DEVICE_INTEL, - sizeof(host_alloc_device), &host_alloc_device, nullptr); + sizeof(host_alloc_device), static_cast(&host_alloc_device), + nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(NULL, host_alloc_device); } @@ -317,7 +320,8 @@ TEST_F(USMMemInfoTest, AllocDevice) { cl_device_id shared_alloc_device = device; err = clGetMemAllocInfoINTEL( context, offset_shared_ptr, CL_MEM_ALLOC_DEVICE_INTEL, - sizeof(shared_alloc_device), &shared_alloc_device, nullptr); + sizeof(shared_alloc_device), static_cast(&shared_alloc_device), + nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(device, shared_alloc_device); } @@ -326,19 +330,21 @@ TEST_F(USMMemInfoTest, AllocDevice) { cl_device_id alloc_device = NULL; err = clGetMemAllocInfoINTEL(context, offset_device_ptr, CL_MEM_ALLOC_DEVICE_INTEL, sizeof(alloc_device), - &alloc_device, nullptr); + static_cast(&alloc_device), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(device, alloc_device); alloc_device = device; err = clGetMemAllocInfoINTEL(context, user_ptr, CL_MEM_ALLOC_DEVICE_INTEL, - sizeof(alloc_device), &alloc_device, nullptr); + sizeof(alloc_device), + static_cast(&alloc_device), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(NULL, alloc_device); alloc_device = device; err = clGetMemAllocInfoINTEL(context, nullptr, CL_MEM_ALLOC_DEVICE_INTEL, - sizeof(alloc_device), &alloc_device, nullptr); + sizeof(alloc_device), + static_cast(&alloc_device), nullptr); EXPECT_SUCCESS(err); EXPECT_EQ(NULL, alloc_device); } diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandCopyBufferRectKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandCopyBufferRectKHR.cpp index 945d86089..61e304d39 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandCopyBufferRectKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandCopyBufferRectKHR.cpp @@ -43,24 +43,24 @@ void copyBufferRect(const byte_vector &src_buffer, byte_vector &dst_buffer, const Region ®ion, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch) { - const size_t src_offset = src_origin[2] * src_slice_pitch + - src_origin[1] * src_row_pitch + src_origin[0]; + const size_t src_offset = (src_origin[2] * src_slice_pitch) + + (src_origin[1] * src_row_pitch) + src_origin[0]; - const size_t dst_offset = dst_origin[2] * dst_slice_pitch + - dst_origin[1] * dst_row_pitch + dst_origin[0]; + const size_t dst_offset = (dst_origin[2] * dst_slice_pitch) + + (dst_origin[1] * dst_row_pitch) + dst_origin[0]; auto src_position = src_buffer.data() + src_offset; auto dst_position = dst_buffer.data() + dst_offset; // for each slice. for (unsigned k = 0; k < region[2]; ++k) { - auto src_slice = src_position + k * src_slice_pitch; - auto dst_slice = dst_position + k * src_slice_pitch; + auto src_slice = src_position + (k * src_slice_pitch); + auto dst_slice = dst_position + (k * src_slice_pitch); // for each row. for (unsigned j = 0; j < region[1]; ++j) { // for each element. - auto src_row = src_slice + j * src_row_pitch; - auto dst_row = dst_slice + j * dst_row_pitch; + auto src_row = src_slice + (j * src_row_pitch); + auto dst_row = dst_slice + (j * dst_row_pitch); std::memcpy(dst_row, src_row, region[0]); } } @@ -150,7 +150,7 @@ TEST_P(CommandCopyBufferRectParamTest, CopyArbitraryRect) { } // Choose parameters so that we get good coverage and catch some edge cases. -std::vector generateParameterizations() { +static std::vector generateParameterizations() { std::vector parameterizations; #define PARAMETERIZATION(name, src_buffer_size, dst_buffer_size, src_origin, \ dst_origin, region, src_row_pitch, src_slice_pitch, \ diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandNDRangeKernelKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandNDRangeKernelKHR.cpp index 588b8be9d..37ab5fffb 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandNDRangeKernelKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clCommandNDRangeKernelKHR.cpp @@ -82,7 +82,7 @@ TEST_F(CommandNDRangeKernelTest, EmptyKernel) { class CommandBufferParallelCopyBase : public CommandNDRangeKernelTest { protected: CommandBufferParallelCopyBase() - : input_data(global_size, 42), output_data(global_size, 0){}; + : input_data(global_size, 42), output_data(global_size, 0) {}; void SetUp() override { UCL_RETURN_ON_FATAL_FAILURE(CommandNDRangeKernelTest::SetUp()); @@ -140,8 +140,10 @@ class CommandBufferParallelCopyBase : public CommandNDRangeKernelTest { kernel = clCreateKernel(program, "parallel_copy", &error); EXPECT_SUCCESS(error); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_buffer)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&dst_buffer))); } void TearDown() override { @@ -176,8 +178,8 @@ class CommandBufferParallelCopyBase : public CommandNDRangeKernelTest { std::vector input_data; std::vector output_data; - constexpr static size_t global_size = 256; - constexpr static size_t data_size_in_bytes = global_size * sizeof(cl_int); + static constexpr size_t global_size = 256; + static constexpr size_t data_size_in_bytes = global_size * sizeof(cl_int); }; class ParallelCopyCommandBuffer : public CommandBufferParallelCopyBase { @@ -534,7 +536,8 @@ TEST_F(CommandNDRangeKernelTest, PODargument) { EXPECT_SUCCESS(error); cl_int data = 42; - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &buffer)); + EXPECT_SUCCESS( + clSetKernelArg(kernel, 0, sizeof(cl_mem), static_cast(&buffer))); EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_int), &data)); // Set up the command buffer and run the command buffer. diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHR.cpp index 3013dcde0..a120f6ecc 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHR.cpp @@ -85,7 +85,8 @@ TEST_F(CommandBufferEnqueueTest, IncrementKernelTwice) { sizeof(cl_int), 0, sizeof(cl_int), 0, nullptr, nullptr)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &counter_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&counter_buffer))); // Set up the command buffer to allow multiple enqueues without a wait. cl_command_buffer_properties_khr properties[3] = { @@ -150,7 +151,8 @@ TEST_F(CommandBufferEnqueueTest, IncrementKernelTwiceDifferentQueues) { sizeof(cl_int), 0, sizeof(cl_int), 0, nullptr, nullptr)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &counter_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&counter_buffer))); // Set up the command buffer to allow multiple enqueues without a wait. cl_command_buffer_properties_khr properties[3] = { @@ -272,8 +274,10 @@ TEST_F(CommandBufferEnqueueTest, ParallelCopyKernel) { data_size_in_bytes, nullptr, &error); ASSERT_SUCCESS(error); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_buffer), &src_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_buffer), &dst_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Set up the command buffer and run the command buffer. cl_command_buffer_khr command_buffer = @@ -398,12 +402,12 @@ class InterleavedCommands : public cl_khr_command_buffer_Test { nullptr, &error); ASSERT_SUCCESS(error); - ASSERT_SUCCESS( - clSetKernelArg(store_zero_kernel, 0, sizeof(dst_buffer), &dst_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(store_one_kernel, 0, sizeof(dst_buffer), &dst_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(store_two_kernel, 0, sizeof(dst_buffer), &dst_buffer)); + ASSERT_SUCCESS(clSetKernelArg(store_zero_kernel, 0, sizeof(dst_buffer), + static_cast(&dst_buffer))); + ASSERT_SUCCESS(clSetKernelArg(store_one_kernel, 0, sizeof(dst_buffer), + static_cast(&dst_buffer))); + ASSERT_SUCCESS(clSetKernelArg(store_two_kernel, 0, sizeof(dst_buffer), + static_cast(&dst_buffer))); } void TearDown() override { @@ -668,7 +672,7 @@ TEST_F(CommandBufferEnqueueTest, EnqueueInLoopWithBlockingRead) { EXPECT_SUCCESS(clFinish(command_queue)); EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(accumulator_buffer), - &accumulator_buffer)); + static_cast(&accumulator_buffer))); // Set up the command buffer. // TODO CA-3358 - After command-buffer cleanup is resolved we should be able @@ -739,7 +743,7 @@ TEST_F(CommandBufferEnqueueTest, EnqueueInLoopWithoutBlockingRead) { EXPECT_SUCCESS(clFinish(command_queue)); EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(accumulator_buffer), - &accumulator_buffer)); + static_cast(&accumulator_buffer))); // Set up the command buffer to allow multiple enqueues without a wait. cl_command_buffer_properties_khr properties[3] = { diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHRWithEvents.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHRWithEvents.cpp index 6f0b47d51..50869e7cb 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHRWithEvents.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clEnqueueCommandBufferKHRWithEvents.cpp @@ -971,8 +971,8 @@ class GetEventInfoTest : public CommandBufferEventTest {}; TEST_F(GetEventInfoTest, EventCommandQueue) { cl_command_queue command_queue = nullptr; EXPECT_SUCCESS(clGetEventInfo(event, CL_EVENT_COMMAND_QUEUE, - sizeof(cl_command_queue), &command_queue, - nullptr)); + sizeof(cl_command_queue), + static_cast(&command_queue), nullptr)); EXPECT_EQ(command_queue, this->command_queue); } @@ -980,7 +980,7 @@ TEST_F(GetEventInfoTest, EventCommandQueue) { TEST_F(GetEventInfoTest, EventContext) { cl_context context = nullptr; EXPECT_SUCCESS(clGetEventInfo(event, CL_EVENT_CONTEXT, sizeof(cl_context), - &context, nullptr)); + static_cast(&context), nullptr)); EXPECT_EQ(context, this->context); } @@ -1256,7 +1256,8 @@ TEST_F(CommandBufferEnqueueEventTest, IncrementKernelTwiceWithUserEvent) { sizeof(cl_int), 0, sizeof(cl_int), 0, nullptr, nullptr)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &counter_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&counter_buffer))); // Set up the command buffer and run the command buffer. cl_command_buffer_properties_khr properties[3] = { diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clGetCommandBufferInfoKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clGetCommandBufferInfoKHR.cpp index d8a48fa94..7157c74c2 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/clGetCommandBufferInfoKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/clGetCommandBufferInfoKHR.cpp @@ -73,9 +73,9 @@ TEST_F(clGetCommandBufferInfoTest, CommandBufferQueues) { command_buffer, CL_COMMAND_BUFFER_QUEUES_KHR, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_command_queue), size); cl_command_queue command_buffer_queue = nullptr; - ASSERT_SUCCESS(clGetCommandBufferInfoKHR(command_buffer, - CL_COMMAND_BUFFER_QUEUES_KHR, size, - &command_buffer_queue, nullptr)); + ASSERT_SUCCESS(clGetCommandBufferInfoKHR( + command_buffer, CL_COMMAND_BUFFER_QUEUES_KHR, size, + static_cast(&command_buffer_queue), nullptr)); ASSERT_EQ(command_queue, command_buffer_queue); } diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer/thread_safety.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer/thread_safety.cpp index 4534799eb..2f63f32b9 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer/thread_safety.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer/thread_safety.cpp @@ -368,9 +368,12 @@ TEST_F(CommandBufferNDRangeThreadSafetyTest, NDRangeInParallel) { dst_buffers.push_back(dst_buffer); // Set the kernel args for each kernel. - EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_a_buffer)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &src_b_buffer)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&src_a_buffer))); + EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&src_b_buffer))); + EXPECT_SUCCESS(clSetKernelArg(kernel, 2, sizeof(cl_mem), + static_cast(&dst_buffer))); } // Fill the input buffers with values for each thread. diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clEnqueueCommandBufferKHRMutability.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clEnqueueCommandBufferKHRMutability.cpp index 40f8f5080..eb165f212 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clEnqueueCommandBufferKHRMutability.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clEnqueueCommandBufferKHRMutability.cpp @@ -61,10 +61,10 @@ class CommandBufferMutableBufferArgTest : public MutableDispatchTest { 0, nullptr, nullptr)); // Set up the initial kernel arguments. - EXPECT_SUCCESS( - clSetKernelArg(parallel_copy_kernel, 0, sizeof(cl_mem), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(parallel_copy_kernel, 1, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(parallel_copy_kernel, 0, sizeof(cl_mem), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(parallel_copy_kernel, 1, sizeof(cl_mem), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { @@ -139,7 +139,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateOutputBufferOnce) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -207,8 +208,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateOutputBufferTwice) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr first_arg{1, sizeof(cl_mem), - &first_updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr first_arg{ + 1, sizeof(cl_mem), static_cast(&first_updated_dst_buffer)}; const cl_mutable_dispatch_config_khr first_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -243,8 +244,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateOutputBufferTwice) { EXPECT_EQ(input_data, first_updated_output_data); // Enqueue the command buffer again updating the output buffer a second time. - const cl_mutable_dispatch_arg_khr second_arg{1, sizeof(cl_mem), - &second_updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr second_arg{ + 1, sizeof(cl_mem), static_cast(&second_updated_dst_buffer)}; const cl_mutable_dispatch_config_khr second_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -318,7 +319,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateInputBufferOnce) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the input buffer. - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &updated_src_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -400,8 +402,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateInputBufferTwice) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the input buffer. - const cl_mutable_dispatch_arg_khr first_arg{0, sizeof(cl_mem), - &first_updated_src_buffer}; + const cl_mutable_dispatch_arg_khr first_arg{ + 0, sizeof(cl_mem), static_cast(&first_updated_src_buffer)}; const cl_mutable_dispatch_config_khr first_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -435,8 +437,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateInputBufferTwice) { EXPECT_EQ(first_updated_input_data, output_data); // Enqueue the command buffer a second time updating the input bufer again. - const cl_mutable_dispatch_arg_khr second_arg{0, sizeof(cl_mem), - &second_updated_src_buffer}; + const cl_mutable_dispatch_arg_khr second_arg{ + 0, sizeof(cl_mem), static_cast(&second_updated_src_buffer)}; const cl_mutable_dispatch_config_khr second_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -516,10 +518,10 @@ TEST_F(CommandBufferMutableBufferArgTest, // Now try and enqueue the command buffer updating the input and output // buffers. - const cl_mutable_dispatch_arg_khr arg_1{0, sizeof(cl_mem), - &updated_src_buffer}; - const cl_mutable_dispatch_arg_khr arg_2{1, sizeof(cl_mem), - &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg_1{ + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; + const cl_mutable_dispatch_arg_khr arg_2{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; cl_mutable_dispatch_arg_khr args[] = {arg_1, arg_2}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, @@ -598,10 +600,10 @@ TEST_F(CommandBufferMutableBufferArgTest, // Now try and enqueue the command buffer updating the input and output // buffers. - const cl_mutable_dispatch_arg_khr arg_1{0, sizeof(cl_mem), - &updated_src_buffer}; - const cl_mutable_dispatch_arg_khr arg_2{1, sizeof(cl_mem), - &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg_1{ + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; + const cl_mutable_dispatch_arg_khr arg_2{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config_1{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -667,7 +669,7 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateToBiggerBufferSize) { // buffer filling it with some value. const auto num_extra_elements = 99; const auto updated_buffer_size_in_bytes = - data_size_in_bytes + num_extra_elements * sizeof(cl_int); + data_size_in_bytes + (num_extra_elements * sizeof(cl_int)); cl_mem updated_dst_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, updated_buffer_size_in_bytes, nullptr, &error); @@ -693,7 +695,8 @@ TEST_F(CommandBufferMutableBufferArgTest, UpdateToBiggerBufferSize) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -762,7 +765,8 @@ TEST_F(CommandBufferMutableBufferArgTest, CheckUpdatePersists) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -860,7 +864,8 @@ TEST_F(CommandBufferMutableBufferArgTest, FillThenNDRange) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -938,7 +943,8 @@ TEST_F(CommandBufferMutableBufferArgTest, NDRangeThenFill) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1019,7 +1025,8 @@ TEST_F(CommandBufferMutableBufferArgTest, FillTwiceThenNDRange) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1099,7 +1106,8 @@ TEST_F(CommandBufferMutableBufferArgTest, CopyBufferThenNDRange) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1181,7 +1189,8 @@ TEST_F(CommandBufferMutableBufferArgTest, CopyBufferRectThenNDRange) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1232,9 +1241,9 @@ TEST_F(CommandBufferMutableBufferArgTest, RegularNDRangeThenMutableNDRange) { EXPECT_SUCCESS(error); EXPECT_SUCCESS(clSetKernelArg(second_parallel_copy_kernel, 0, sizeof(cl_mem), - &first_extra_buffer)); + static_cast(&first_extra_buffer))); EXPECT_SUCCESS(clSetKernelArg(second_parallel_copy_kernel, 1, sizeof(cl_mem), - &second_extra_buffer)); + static_cast(&second_extra_buffer))); EXPECT_SUCCESS(clCommandNDRangeKernelKHR( command_buffer, nullptr, nullptr, second_parallel_copy_kernel, 1, nullptr, @@ -1270,7 +1279,8 @@ TEST_F(CommandBufferMutableBufferArgTest, RegularNDRangeThenMutableNDRange) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the output buffer. - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1349,9 +1359,11 @@ class CommandBufferMultiMutableBufferArgTest // Set up the initial kernel arguments. EXPECT_SUCCESS(clSetKernelArg(second_parallel_copy_kernel, 0, - sizeof(cl_mem), &second_src_buffer)); + sizeof(cl_mem), + static_cast(&second_src_buffer))); EXPECT_SUCCESS(clSetKernelArg(second_parallel_copy_kernel, 1, - sizeof(cl_mem), &second_dst_buffer)); + sizeof(cl_mem), + static_cast(&second_dst_buffer))); EXPECT_SUCCESS(error); // Enqueue a mutable dispatch to the command buffer. @@ -1424,7 +1436,8 @@ TEST_F(CommandBufferMultiMutableBufferArgTest, UpdateSingleDispatch) { // Now try and enqueue the command buffer updating the output buffer of the // first nd range. - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &updated_src_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1512,8 +1525,8 @@ TEST_F(CommandBufferMultiMutableBufferArgTest, UpdateMultipleDispatches) { // Now try and enqueue the command buffer updating the input buffer of both // nd ranges. - const cl_mutable_dispatch_arg_khr first_arg{0, sizeof(cl_mem), - &first_updated_src_buffer}; + const cl_mutable_dispatch_arg_khr first_arg{ + 0, sizeof(cl_mem), static_cast(&first_updated_src_buffer)}; const cl_mutable_dispatch_config_khr first_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1529,8 +1542,8 @@ TEST_F(CommandBufferMultiMutableBufferArgTest, UpdateMultipleDispatches) { nullptr, nullptr}; - const cl_mutable_dispatch_arg_khr second_arg{0, sizeof(cl_mem), - &second_updated_src_buffer}; + const cl_mutable_dispatch_arg_khr second_arg{ + 0, sizeof(cl_mem), static_cast(&second_updated_src_buffer)}; const cl_mutable_dispatch_config_khr second_dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1617,10 +1630,10 @@ TEST_F(MutableDispatchTest, UpdateConstantBuffer) { nullptr, nullptr)); // Set up the initial kernel arguments. - EXPECT_SUCCESS( - clSetKernelArg(parallel_copy_kernel, 0, sizeof(src_buffer), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(parallel_copy_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(parallel_copy_kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(parallel_copy_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { @@ -1669,7 +1682,8 @@ TEST_F(MutableDispatchTest, UpdateConstantBuffer) { EXPECT_EQ(input_data, output_data); // Now try and enqueue the command buffer updating the input buffer. - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &updated_src_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1956,10 +1970,10 @@ class DISABLED_CommandBufferMutableNullArgTest : public MutableDispatchTest { TEST_F(DISABLED_CommandBufferMutableNullArgTest, UpdateInputBufferToNullByValue) { // Set up the initial kernel arguments. - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_ndrange_kernel_command_properties_khr mutable_properties[3] = { @@ -2019,10 +2033,10 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, TEST_F(DISABLED_CommandBufferMutableNullArgTest, UpdateInputBufferToNullByAddress) { // Set up the initial kernel arguments. - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_mutable_command_khr command_handle; @@ -2053,7 +2067,8 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, // Update the input to pointer to null. const cl_int *null = nullptr; - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &null}; + const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), + static_cast(&null)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -2085,8 +2100,8 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, // Set up the initial kernel arguments. EXPECT_SUCCESS( clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), nullptr)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_mutable_command_khr command_handle; @@ -2116,7 +2131,8 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, EXPECT_EQ(output_data, std::vector(global_size, 0x1)); // Update the input to null. - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &src_buffer}; + const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), + static_cast(&src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -2147,10 +2163,10 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, UpdateInputBufferFromNullByAddress) { // Set up the initial kernel arguments. const cl_int *null = nullptr; - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), &null)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), + static_cast(&null))); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_mutable_command_khr command_handle; @@ -2180,7 +2196,8 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, EXPECT_EQ(output_data, std::vector(global_size, 0x1)); // Update the input to null. - const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &src_buffer}; + const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), + static_cast(&src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -2209,10 +2226,10 @@ TEST_F(DISABLED_CommandBufferMutableNullArgTest, TEST_F(DISABLED_CommandBufferMutableNullArgTest, CheckUpdatePersists) { // Set up the initial kernel arguments. - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_ndrange_kernel_command_properties_khr mutable_properties[3] = { @@ -2298,10 +2315,10 @@ class DISABLED_CommandBufferMultiMutableNullArgTest DISABLED_CommandBufferMutableNullArgTest::SetUp()); // Set up the initial kernel arguments of the first ND range. - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), &src_buffer)); - EXPECT_SUCCESS( - clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 0, sizeof(src_buffer), + static_cast(&src_buffer))); + EXPECT_SUCCESS(clSetKernelArg(null_test_kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_ndrange_kernel_command_properties_khr mutable_properties[3] = { @@ -2327,9 +2344,9 @@ class DISABLED_CommandBufferMultiMutableNullArgTest // Set up the initial kernel arguments of the second nd range. EXPECT_SUCCESS(clSetKernelArg(second_null_test_kernel, 0, sizeof(cl_mem), - &second_src_buffer)); + static_cast(&second_src_buffer))); EXPECT_SUCCESS(clSetKernelArg(second_null_test_kernel, 1, sizeof(cl_mem), - &second_dst_buffer)); + static_cast(&second_dst_buffer))); // Enqueue a mutable dispatch to the command buffer. EXPECT_SUCCESS(clCommandNDRangeKernelKHR( @@ -2534,8 +2551,8 @@ class CommandBufferMutablePODArgTest : public MutableDispatchTest { // Set up the initial kernel arguments. EXPECT_SUCCESS( clSetKernelArg(broadcast_kernel, 0, sizeof(cl_int), &input_value)); - EXPECT_SUCCESS( - clSetKernelArg(broadcast_kernel, 1, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(broadcast_kernel, 1, sizeof(cl_mem), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { @@ -2865,7 +2882,7 @@ class CommandBufferMultiMutablePODArgTest EXPECT_SUCCESS(clSetKernelArg(second_broadcast_kernel, 0, sizeof(cl_int), &second_input_value)); EXPECT_SUCCESS(clSetKernelArg(second_broadcast_kernel, 1, sizeof(cl_mem), - &second_dst_buffer)); + static_cast(&second_dst_buffer))); // Enqueue a mutable dispatch to the command buffer. cl_ndrange_kernel_command_properties_khr mutable_properties[3] = { @@ -3104,8 +3121,8 @@ class CommandBufferMutablePODMultiArgTest : public MutableDispatchTest { clSetKernelArg(broadcast_kernel, 0, sizeof(cl_int), &input_x_value)); EXPECT_SUCCESS( clSetKernelArg(broadcast_kernel, 1, sizeof(cl_int), &input_y_value)); - EXPECT_SUCCESS( - clSetKernelArg(broadcast_kernel, 2, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(broadcast_kernel, 2, sizeof(cl_mem), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { @@ -3338,7 +3355,8 @@ TEST_F(CommandBufferMutableStructArgTest, UpdateInputOnce) { // Set up the initial kernel arguments. EXPECT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(test_struct), &first_value)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_buffer), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(dst_buffer), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clGetMutableCommandInfoKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clGetMutableCommandInfoKHR.cpp index 30ee82868..ba1e1797d 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clGetMutableCommandInfoKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clGetMutableCommandInfoKHR.cpp @@ -68,7 +68,7 @@ struct MutableCommandInfoTest : MutableDispatchTest { cl_kernel kernel = nullptr; std::array mutable_properties; - constexpr static size_t global_size = 8; + static constexpr size_t global_size = 8; }; TEST_F(MutableCommandInfoTest, InvalidCommandBuffer) { @@ -99,7 +99,7 @@ TEST_F(MutableCommandInfoTest, MutableCommandCommandQueue) { cl_command_queue command_handle_queue = nullptr; ASSERT_SUCCESS(clGetMutableCommandInfoKHR( command_handle, CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR, size, - &command_handle_queue, nullptr)); + static_cast(&command_handle_queue), nullptr)); ASSERT_EQ(command_queue, command_handle_queue); } @@ -112,7 +112,7 @@ TEST_F(MutableCommandInfoTest, MutableCommandCommandBuffer) { cl_command_buffer_khr command_handle_buffer = nullptr; ASSERT_SUCCESS(clGetMutableCommandInfoKHR( command_handle, CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR, size, - &command_handle_buffer, nullptr)); + static_cast(&command_handle_buffer), nullptr)); ASSERT_EQ(command_buffer, command_handle_buffer); } @@ -150,9 +150,9 @@ TEST_F(MutableCommandInfoTest, MutableDispatchKernel) { command_handle, CL_MUTABLE_DISPATCH_KERNEL_KHR, 0, nullptr, &size)); ASSERT_EQ(sizeof(cl_kernel), size); cl_kernel command_handle_kernel = nullptr; - ASSERT_SUCCESS( - clGetMutableCommandInfoKHR(command_handle, CL_MUTABLE_DISPATCH_KERNEL_KHR, - size, &command_handle_kernel, nullptr)); + ASSERT_SUCCESS(clGetMutableCommandInfoKHR( + command_handle, CL_MUTABLE_DISPATCH_KERNEL_KHR, size, + static_cast(&command_handle_kernel), nullptr)); ASSERT_EQ(kernel, command_handle_kernel); } diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clUpdateMutableCommandsKHR.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clUpdateMutableCommandsKHR.cpp index 039c02b13..fd7fb51f2 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clUpdateMutableCommandsKHR.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/clUpdateMutableCommandsKHR.cpp @@ -21,7 +21,7 @@ class CommandBufferUpdateNDKernel : public MutableDispatchTest { protected: CommandBufferUpdateNDKernel() - : input_data(global_size, 42), output_data(global_size, 0){}; + : input_data(global_size, 42), output_data(global_size, 0) {}; virtual void SetUp() override { UCL_RETURN_ON_FATAL_FAILURE(MutableDispatchTest::SetUp()); @@ -67,8 +67,10 @@ class CommandBufferUpdateNDKernel : public MutableDispatchTest { kernel = clCreateKernel(program, "parallel_copy", &error); ASSERT_SUCCESS(error); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_buffer)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &dst_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&src_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&dst_buffer))); } virtual void TearDown() override { @@ -104,8 +106,8 @@ class CommandBufferUpdateNDKernel : public MutableDispatchTest { std::vector input_data; std::vector output_data; - constexpr static size_t global_size = 256; - constexpr static size_t data_size_in_bytes = global_size * sizeof(cl_int); + static constexpr size_t global_size = 256; + static constexpr size_t data_size_in_bytes = global_size * sizeof(cl_int); }; // Return CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid @@ -329,7 +331,8 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidHandle) { &global_size, nullptr, 0, nullptr, nullptr, &new_command_handle)); EXPECT_SUCCESS(clFinalizeCommandBufferKHR(new_command_buffer)); - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), + static_cast(&dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -451,7 +454,8 @@ TEST_F(CommandBufferUpdateNDKernel, ImmutablePropertyBit) { &global_size, nullptr, 0, nullptr, nullptr, &command_handle)); ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), + static_cast(&dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -505,7 +509,8 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgList) { ASSERT_EQ_ERRCODE(CL_INVALID_VALUE, clUpdateMutableCommandsKHR( command_buffer, &mutable_config)); - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), + static_cast(&dst_buffer)}; dispatch_config = {CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, command_handle, @@ -536,7 +541,7 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgIndex) { ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); const cl_mutable_dispatch_arg_khr arg = {3 /* arg_index */, sizeof(cl_mem), - &src_buffer}; + static_cast(&src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -602,8 +607,8 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgValue) { &global_size, nullptr, 0, nullptr, nullptr, &command_handle)); EXPECT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); - const cl_mutable_dispatch_arg_khr arg = {0, sizeof(cl_mem), - &image /* arg_value */}; + const cl_mutable_dispatch_arg_khr arg = { + 0, sizeof(cl_mem), static_cast(&image) /* arg_value */}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -638,7 +643,8 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgSize) { &global_size, nullptr, 0, nullptr, nullptr, &command_handle)); ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); - const cl_mutable_dispatch_arg_khr arg = {0, 2 /* arg_size */, &src_buffer}; + const cl_mutable_dispatch_arg_khr arg = {0, 2 /* arg_size */, + static_cast(&src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -707,7 +713,8 @@ TEST_F(CommandBufferUpdateNDKernel, IterativeArgumentUpdate) { // Update both the input and output buffer, reusing the same // cl_mutable_dispatch_arg_khr struct - cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &updated_src_buffer}; + cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), + static_cast(&updated_src_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -728,7 +735,7 @@ TEST_F(CommandBufferUpdateNDKernel, IterativeArgumentUpdate) { // Reuse argument update struct for output buffer arg.arg_index = 1; - arg.arg_value = &updated_dst_buffer; + arg.arg_value = static_cast(&updated_dst_buffer); EXPECT_SUCCESS(clUpdateMutableCommandsKHR(command_buffer, &mutable_config)); // Enqueue the command buffer again @@ -797,7 +804,8 @@ TEST_F(CommandBufferUpdateNDKernel, OverwriteArgumentUpdate) { // Update both the input and output buffer, reusing the same // cl_mutable_dispatch_arg_khr struct - cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &unused_dst_buffer}; + cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), + static_cast(&unused_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -818,7 +826,7 @@ TEST_F(CommandBufferUpdateNDKernel, OverwriteArgumentUpdate) { // Reuse argument update struct for output buffer arg.arg_index = 1; - arg.arg_value = &updated_dst_buffer; + arg.arg_value = static_cast(&updated_dst_buffer); EXPECT_SUCCESS(clUpdateMutableCommandsKHR(command_buffer, &mutable_config)); // Enqueue the command buffer again @@ -873,7 +881,8 @@ TEST_F(CommandBufferUpdateNDKernel, NoMutablePropertiesSet) { EXPECT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); // Update the output buffer - const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg{ + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1000,8 +1009,8 @@ TEST_F(CommandBufferSimultaneousUpdate, UpdatePending) { // Update the kernel inputs & output arguments cl_mutable_dispatch_arg_khr args[2] = { - {0, sizeof(cl_mem), &updated_src_buffer}, - {1, sizeof(cl_mem), &updated_dst_buffer}}; + {0, sizeof(cl_mem), static_cast(&updated_src_buffer)}, + {1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1057,8 +1066,8 @@ TEST_F(CommandBufferSimultaneousUpdate, ConsecutiveUpdate) { 0, nullptr, simultaneous_command_buffer, 1, &user_event, nullptr)); // Update the kernel input argument - const cl_mutable_dispatch_arg_khr input_arg = {0, sizeof(cl_mem), - &updated_src_buffer}; + const cl_mutable_dispatch_arg_khr input_arg = { + 0, sizeof(cl_mem), static_cast(&updated_src_buffer)}; cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, @@ -1079,8 +1088,8 @@ TEST_F(CommandBufferSimultaneousUpdate, ConsecutiveUpdate) { clUpdateMutableCommandsKHR(simultaneous_command_buffer, &mutable_config)); // Update the kernel output argument - const cl_mutable_dispatch_arg_khr output_args = {1, sizeof(cl_mem), - &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr output_args = { + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; dispatch_config.arg_list = &output_args; ASSERT_SUCCESS( clUpdateMutableCommandsKHR(simultaneous_command_buffer, &mutable_config)); @@ -1122,9 +1131,10 @@ TEST_F(CommandBufferSimultaneousUpdate, MultipleCommands) { simultaneous_command_buffer, nullptr, nullptr, kernel, 1, nullptr, &global_size, nullptr, 0, nullptr, nullptr, &command_handle)); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &dst_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 1, sizeof(cl_mem), &updated_src_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&dst_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&updated_src_buffer))); cl_mutable_command_khr command_handle2; ASSERT_SUCCESS(clCommandNDRangeKernelKHR( @@ -1139,10 +1149,10 @@ TEST_F(CommandBufferSimultaneousUpdate, MultipleCommands) { 0, nullptr, simultaneous_command_buffer, 1, &user_event, nullptr)); // Update the output of command 1 and input of command 2 - const cl_mutable_dispatch_arg_khr arg1 = {1, sizeof(cl_mem), - &updated_dst_buffer}; - const cl_mutable_dispatch_arg_khr arg2 = {0, sizeof(cl_mem), - &updated_dst_buffer}; + const cl_mutable_dispatch_arg_khr arg1 = { + 1, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; + const cl_mutable_dispatch_arg_khr arg2 = { + 0, sizeof(cl_mem), static_cast(&updated_dst_buffer)}; cl_mutable_dispatch_config_khr dispatch_configs[2] = { {CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, command_handle, 1, 0, 0, 0, &arg1, nullptr, nullptr, nullptr, nullptr, nullptr}, diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/thread_safety.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/thread_safety.cpp index 2bffe0756..2321aa36d 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/thread_safety.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/thread_safety.cpp @@ -80,7 +80,8 @@ TEST_F(MutableDispatchThreadSafetyTest, UpdateInParallel) { const cl_int initial_value = 42; EXPECT_SUCCESS( clSetKernelArg(kernel, 0, sizeof(initial_value), &initial_value)); - EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &dst_buffer)); + EXPECT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&dst_buffer))); // Create command-buffer with mutable flag so we can update it cl_command_buffer_properties_khr properties[3] = { diff --git a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/usm_arg_update.cpp b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/usm_arg_update.cpp index 66426c968..59e2fdfc1 100644 --- a/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/usm_arg_update.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_command_buffer_mutable_dispatch/usm_arg_update.cpp @@ -76,7 +76,8 @@ void kernel usm_copy(__global int* in, kernel = clCreateKernel(program, "usm_copy", &error); ASSERT_SUCCESS(error); - ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), &out_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(cl_mem), + static_cast(&out_buffer))); } void TearDown() override { @@ -120,8 +121,8 @@ void kernel usm_copy(__global int* in, cl_program program = nullptr; cl_kernel kernel = nullptr; - constexpr static size_t global_size = 256; - constexpr static size_t data_size_in_bytes = global_size * sizeof(cl_int); + static constexpr size_t global_size = 256; + static constexpr size_t data_size_in_bytes = global_size * sizeof(cl_int); }; // Return CL_INVALID_VALUE if arg_svm_list is NULL and num_svm_args > 0, @@ -225,7 +226,7 @@ TEST_F(MutableDispatchUSMTest, InvalidArgValue) { ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer)); - const cl_mutable_dispatch_arg_khr arg{0, 0, &out_buffer}; + const cl_mutable_dispatch_arg_khr arg{0, 0, static_cast(&out_buffer)}; const cl_mutable_dispatch_config_khr dispatch_config{ CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR, nullptr, diff --git a/source/cl/test/UnitCL/source/cl_khr_extended_async_copies/extended_async.cpp b/source/cl/test/UnitCL/source/cl_khr_extended_async_copies/extended_async.cpp index 686cb3550..a3a83f8fa 100644 --- a/source/cl/test/UnitCL/source/cl_khr_extended_async_copies/extended_async.cpp +++ b/source/cl/test/UnitCL/source/cl_khr_extended_async_copies/extended_async.cpp @@ -27,11 +27,11 @@ const size_t local_wg_size = 16; // Vector addition: C[x] = A[x] + B[x]; kts::Reference1D vaddInA = [](size_t x) { - return kts::Ref_Identity(x) * 3 + 27; + return (kts::Ref_Identity(x) * 3) + 27; }; kts::Reference1D vaddInB = [](size_t x) { - return kts::Ref_Identity(x) * 7 + 41; + return (kts::Ref_Identity(x) * 7) + 41; }; kts::Reference1D vaddOutC = [](size_t x) { diff --git a/source/cl/test/UnitCL/source/ctz.cpp b/source/cl/test/UnitCL/source/ctz.cpp index f6a398f25..1cece57da 100644 --- a/source/cl/test/UnitCL/source/ctz.cpp +++ b/source/cl/test/UnitCL/source/ctz.cpp @@ -94,10 +94,10 @@ class CtzTest : public ucl::CommandQueueTest { ASSERT_SUCCESS(error_code); // Set the kernel arguments. - ASSERT_SUCCESS( - clSetKernelArg(kernel, 0, sizeof(input_buffer), &input_buffer)); - ASSERT_SUCCESS( - clSetKernelArg(kernel, 1, sizeof(output_buffer), &output_buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(input_buffer), + static_cast(&input_buffer))); + ASSERT_SUCCESS(clSetKernelArg(kernel, 1, sizeof(output_buffer), + static_cast(&output_buffer))); } template diff --git a/source/cl/test/UnitCL/source/kts/execution.cpp b/source/cl/test/UnitCL/source/kts/execution.cpp index ba865d14f..fbece1484 100644 --- a/source/cl/test/UnitCL/source/kts/execution.cpp +++ b/source/cl/test/UnitCL/source/kts/execution.cpp @@ -118,10 +118,12 @@ bool kts::ucl::BaseExecution::LoadSource(const std::string &path) { return false; } if (fseek(f, 0, SEEK_END)) { + (void)fclose(f); return false; } const long size = ftell(f); if (size < 0) { + (void)fclose(f); return false; } source_.resize(size); @@ -503,7 +505,7 @@ void kts::ucl::BaseExecution::RunGenericND(cl_uint numDims, return; } } - clSetKernelArg(kernel_, i, sizeof(cl_mem), &buffer); + clSetKernelArg(kernel_, i, sizeof(cl_mem), static_cast(&buffer)); } else if (arg->GetKind() == kts::ePrimitive) { kts::Primitive *primitive = arg->GetPrimitive(); clSetKernelArg(kernel_, i, primitive->GetSize(), primitive->GetAddress()); @@ -516,7 +518,8 @@ void kts::ucl::BaseExecution::RunGenericND(cl_uint numDims, Fail("Could not create sampler", err); return; } - clSetKernelArg(kernel_, i, sizeof(cl_sampler), &sampler); + clSetKernelArg(kernel_, i, sizeof(cl_sampler), + static_cast(&sampler)); arg->SetSampler(sampler); } else if (arg->GetKind() == kts::eInputImage) { const kts::ucl::ImageDesc &image_desc = arg->GetImageDesc(); @@ -539,7 +542,7 @@ void kts::ucl::BaseExecution::RunGenericND(cl_uint numDims, return; } arg->SetBuffer(image); - clSetKernelArg(kernel_, i, sizeof(cl_mem), &image); + clSetKernelArg(kernel_, i, sizeof(cl_mem), static_cast(&image)); } } diff --git a/source/cl/test/UnitCL/source/ktst_builtins.cpp b/source/cl/test/UnitCL/source/ktst_builtins.cpp index 67a391ee1..c45729174 100644 --- a/source/cl/test/UnitCL/source/ktst_builtins.cpp +++ b/source/cl/test/UnitCL/source/ktst_builtins.cpp @@ -44,7 +44,7 @@ TEST_P(Execution, Builtins_02_Fmax_Vector_Scalar_NaN) { TEST_P(Execution, Builtins_03_Mad_Conversions) { kts::Reference1D refOut = [](size_t) { - return static_cast(10.0f * 1.2f + 20.0f); + return static_cast((10.0f * 1.2f) + 20.0f); }; AddPrimitive(static_cast(10)); AddPrimitive(20); @@ -56,7 +56,7 @@ TEST_P(Execution, Builtins_03_Mad_Conversions) { TEST_P(Execution, Builtins_04_Mad24_Conversions) { kts::Reference1D refOut = [](size_t) { - return static_cast(10 * 1 + 20); + return static_cast((10 * 1) + 20); }; AddPrimitive(static_cast(10)); AddPrimitive(20); diff --git a/source/cl/test/UnitCL/source/ktst_compiler.cpp b/source/cl/test/UnitCL/source/ktst_compiler.cpp index 3c27fa17e..0e53dfff1 100644 --- a/source/cl/test/UnitCL/source/ktst_compiler.cpp +++ b/source/cl/test/UnitCL/source/ktst_compiler.cpp @@ -39,8 +39,8 @@ TEST_P(Execution, Attribute_01_reqd_work_group_size) { cl_mem buffer = clCreateBuffer(this->context, CL_MEM_WRITE_ONLY, buffer_size, nullptr, &error); ASSERT_SUCCESS(error); - EXPECT_EQ_ERRCODE(CL_SUCCESS, - clSetKernelArg(this->kernel_, 0, sizeof(buffer), &buffer)); + EXPECT_EQ_ERRCODE(CL_SUCCESS, clSetKernelArg(this->kernel_, 0, sizeof(buffer), + static_cast(&buffer))); const auto max_work_items_sizes = this->getDeviceMaxWorkItemSizes(); for (size_t i = 0; i < 3; i++) { diff --git a/source/cl/test/UnitCL/source/ktst_compiler_barrier.cpp b/source/cl/test/UnitCL/source/ktst_compiler_barrier.cpp index f894dda0b..03da02652 100644 --- a/source/cl/test/UnitCL/source/ktst_compiler_barrier.cpp +++ b/source/cl/test/UnitCL/source/ktst_compiler_barrier.cpp @@ -108,7 +108,7 @@ TEST_P(Execution, Compiler_Barrier_04_Mutually_Exclusive_Barriers) { kts::Reference1D refOut = [&](size_t x) { const cl_int lid = static_cast(x) % kts::localN; const size_t group = x / kts::localN; - return (group == offset) ? lid * 3 : lid * 3 + 1; + return (group == offset) ? lid * 3 : (lid * 3) + 1; }; AddMacro("ARRAY_SIZE", (int)ARRAY_SIZE); @@ -126,7 +126,7 @@ TEST_P(Execution, Compiler_Barrier_05_Simple_Mutually_Exclusive_Barriers) { kts::Reference1D refOut = [&](size_t x) { const cl_int lid = static_cast(x) % kts::localN; const size_t group = x / kts::localN; - return (group == offset) ? lid * 3 : lid * 3 + 1; + return (group == offset) ? lid * 3 : (lid * 3) + 1; }; AddInputBuffer(ARRAY_SIZE, refIn); AddOutputBuffer(kts::N, refOut); diff --git a/source/cl/test/UnitCL/source/ktst_conversions.cpp b/source/cl/test/UnitCL/source/ktst_conversions.cpp index 1591202fb..6692541a3 100644 --- a/source/cl/test/UnitCL/source/ktst_conversions.cpp +++ b/source/cl/test/UnitCL/source/ktst_conversions.cpp @@ -173,9 +173,8 @@ struct ConvertRefHelper { // Signed integer types template - static bool undef( - const typename std::enable_if, T>::type x, - const bool) { + static bool undef(const std::enable_if_t, T> x, + const bool) { // Signed 32 & 64 bit integer types which are too large to represent in // half precision have an undefined result, and saturation isn't valid return (x > TypeInfo::max_int_bits) || @@ -184,9 +183,8 @@ struct ConvertRefHelper { // Unsigned integer types template - static bool undef( - const typename std::enable_if, T>::type x, - const bool) { + static bool undef(const std::enable_if_t, T> x, + const bool) { // Unsigned 32 & 64 bit integer types which are too large to represent in // half precision have an undefined result, and saturation isn't valid return x > TypeInfo::max_int_bits; diff --git a/source/cl/test/UnitCL/source/ktst_dimensions.cpp b/source/cl/test/UnitCL/source/ktst_dimensions.cpp index 1dd73ec18..403b4117d 100644 --- a/source/cl/test/UnitCL/source/ktst_dimensions.cpp +++ b/source/cl/test/UnitCL/source/ktst_dimensions.cpp @@ -32,11 +32,11 @@ class NDimensions { NDimensions(std::initializer_list g, std::initializer_list l, std::initializer_list a) - : global(g), local(l), active(a){}; + : global(g), local(l), active(a) {}; // If there is no active work group. NDimensions(std::initializer_list g, std::initializer_list l) - : global(g), local(l), active({0, 0, 0}){}; + : global(g), local(l), active({0, 0, 0}) {}; size_t size() const { // Calculate product. @@ -73,7 +73,7 @@ class NDimensions { }; template -std::ostream &operator<<(std::ostream &out, const std::vector &v) { +static std::ostream &operator<<(std::ostream &out, const std::vector &v) { out << "{"; for (size_t index = 0, count = v.size(); index < count; index++) { out << v[index]; @@ -85,7 +85,7 @@ std::ostream &operator<<(std::ostream &out, const std::vector &v) { return out; } -std::ostream &operator<<(std::ostream &out, const NDimensions &nd) { +static std::ostream &operator<<(std::ostream &out, const NDimensions &nd) { out << "NDimensions{" << ".global" << nd.global << ", " << ".local" << nd.local << ", " diff --git a/source/cl/test/UnitCL/source/ktst_dma.cpp b/source/cl/test/UnitCL/source/ktst_dma.cpp index a256495cc..5dcaddf32 100644 --- a/source/cl/test/UnitCL/source/ktst_dma.cpp +++ b/source/cl/test/UnitCL/source/ktst_dma.cpp @@ -32,11 +32,11 @@ const size_t local_wg_size = 16; // Vector addition: C[x] = A[x] + B[x]; kts::Reference1D vaddInA = [](size_t x) { - return kts::Ref_Identity(x) * 3 + 27; + return (kts::Ref_Identity(x) * 3) + 27; }; kts::Reference1D vaddInB = [](size_t x) { - return kts::Ref_Identity(x) * 7 + 41; + return (kts::Ref_Identity(x) * 7) + 41; }; kts::Reference1D vaddOutC = [](size_t x) { @@ -198,7 +198,7 @@ class DmaAutoConvolutionExecute : public Execution { cl_uint total = totalStart; const cl_uint dstYStride = gsizeX; const cl_uint srcYStride = dstYStride + 16; - cl_uint srcIndex = gidY * srcYStride + gidX + 8; + cl_uint srcIndex = (gidY * srcYStride) + gidX + 8; srcIndex += srcYStride; for (uint32_t yy = 0; yy < 3; yy++) { for (uint32_t xx = 0; xx < 3; xx++) { @@ -206,7 +206,7 @@ class DmaAutoConvolutionExecute : public Execution { continue; } if (((1 << xx) & maskLoop1) && ((1 << xx) & maskLoop2)) { - const cl_uint srcIndexLoop = yy * srcYStride + srcIndex + xx - 1; + const cl_uint srcIndexLoop = (yy * srcYStride) + srcIndex + xx - 1; total = total + inA(srcIndexLoop); } } diff --git a/source/cl/test/UnitCL/source/ktst_geometric.cpp b/source/cl/test/UnitCL/source/ktst_geometric.cpp index beaa7052b..1216378e9 100644 --- a/source/cl/test/UnitCL/source/ktst_geometric.cpp +++ b/source/cl/test/UnitCL/source/ktst_geometric.cpp @@ -251,7 +251,7 @@ unsigned GeometricParamExecution::GeometricFillBuffers( const cl_float low = -32.0f; const cl_float high = 32.0f; - const cl_float clamped = (1.0f - normalized) * low + normalized * high; + const cl_float clamped = ((1.0f - normalized) * low) + (normalized * high); return ConvertFloatToHalf(clamped); }; @@ -322,7 +322,7 @@ TEST_P(HalfGeometricBuiltins, Geometric_01_Half_Dot) { // CTS uses an absolute error tolerance for 32-bit float dot validation, so // use the same here method const cl_float err_tolerance = - max_value * max_value * cl_float(2 * vec_width - 1); + max_value * max_value * cl_float((2 * vec_width) - 1); // Check for overflow in tolerance calculation which should be done in // same precision as we're testing, but fp16 isn't available on host. diff --git a/source/cl/test/UnitCL/source/ktst_precision.cpp b/source/cl/test/UnitCL/source/ktst_precision.cpp index 765d0e1f7..053e087ba 100644 --- a/source/cl/test/UnitCL/source/ktst_precision.cpp +++ b/source/cl/test/UnitCL/source/ktst_precision.cpp @@ -1278,7 +1278,7 @@ TEST_P(HalfMathBuiltins, Precision_53_Half_mix) { sub = std::copysign(0.0f, sub); } - return x + sub * a; + return x + (sub * a); }; const std::function undef_check( @@ -1304,7 +1304,7 @@ TEST_P(HalfMathBuiltins, Precision_53_Half_mix_scalar) { sub = std::copysign(0.0f, sub); } - return x + sub * a; + return x + (sub * a); }; const std::function undef_check( diff --git a/source/cl/test/UnitCL/source/ktst_printf.cpp b/source/cl/test/UnitCL/source/ktst_printf.cpp index edbeed446..c21eae021 100644 --- a/source/cl/test/UnitCL/source/ktst_printf.cpp +++ b/source/cl/test/UnitCL/source/ktst_printf.cpp @@ -503,7 +503,7 @@ TEST_P(PrintfExecution, Printf_16_Floats_Vectors) { namespace Printf_17_Float_Formatting { const cl_int num_inputs = 10; -kts::Reference1D Ref = [](size_t x) { +static kts::Reference1D Ref = [](size_t x) { switch (x % num_inputs) { default: case 0: diff --git a/source/cl/test/UnitCL/source/ktst_regression_02.cpp b/source/cl/test/UnitCL/source/ktst_regression_02.cpp index b5126bab4..cf949d30b 100644 --- a/source/cl/test/UnitCL/source/ktst_regression_02.cpp +++ b/source/cl/test/UnitCL/source/ktst_regression_02.cpp @@ -79,8 +79,8 @@ struct ArraySizeAndTypeParam final { : arraySize(size), varType(type) {} }; -std::ostream &operator<<(std::ostream &out, - const ArraySizeAndTypeParam ¶m) { +static std::ostream &operator<<(std::ostream &out, + const ArraySizeAndTypeParam ¶m) { out << "ArraySizeAndTypeParam{.arraySize{" << param.arraySize << ", .varType{\"" << param.varType << "\"}}"; return out; @@ -815,7 +815,7 @@ TEST_P(Execution, Regression_45_Mad_Sat_Short3_Codegen) { }; kts::Reference1D refOut = [&refIn](size_t x) { const cl_long y = static_cast(refIn(x)); - const cl_long mad = y * y + y; // mad_sat == a*b+c + const cl_long mad = (y * y) + y; // mad_sat == a*b+c const cl_long mad_sat = std::min(32767, std::max(-32768, mad)); return static_cast(mad_sat); @@ -833,7 +833,7 @@ TEST_P(Execution, Regression_45_Mad_Sat_Ushort3_Codegen) { }; kts::Reference1D refOut = [&refIn](size_t x) { const cl_ulong y = static_cast(refIn(x)); - const cl_ulong mad = y * y + y; // mad_sat == a*b+c + const cl_ulong mad = (y * y) + y; // mad_sat == a*b+c const cl_ulong mad_sat = std::min(65535, mad); return static_cast(mad_sat); }; @@ -889,19 +889,19 @@ const cl_image_desc desc = []() { image_desc.buffer = nullptr; return image_desc; }(); -cl_image_format format = {CL_RGBA, CL_UNSIGNED_INT8}; -cl_bool normalized_coords = CL_TRUE; -cl_addressing_mode addressing_mode_repeat = CL_ADDRESS_REPEAT; -cl_addressing_mode addressing_mode_clamp = CL_ADDRESS_CLAMP_TO_EDGE; -cl_filter_mode filter_mode = CL_FILTER_NEAREST; +static cl_image_format format = {CL_RGBA, CL_UNSIGNED_INT8}; +static cl_bool normalized_coords = CL_TRUE; +static cl_addressing_mode addressing_mode_repeat = CL_ADDRESS_REPEAT; +static cl_addressing_mode addressing_mode_clamp = CL_ADDRESS_CLAMP_TO_EDGE; +static cl_filter_mode filter_mode = CL_FILTER_NEAREST; -kts::Reference1D refIn = [](size_t x) { +static kts::Reference1D refIn = [](size_t x) { cl_char c = static_cast(x); cl_char4 a4 = {{c, c, c, c}}; return a4; }; -kts::Reference1D refOut = [](size_t x) { +static kts::Reference1D refOut = [](size_t x) { const size_t index = x >> 1; float normf = (static_cast(index) + 0.05f) / diff --git a/source/cl/test/UnitCL/source/ktst_regression_03.cpp b/source/cl/test/UnitCL/source/ktst_regression_03.cpp index fe8bc1ade..93ae36b74 100644 --- a/source/cl/test/UnitCL/source/ktst_regression_03.cpp +++ b/source/cl/test/UnitCL/source/ktst_regression_03.cpp @@ -274,8 +274,8 @@ struct GlobalRangeAndLocalRange final { : global_range{global_1d, global_2d}, local_range{local_1d, local_2d} {} }; -std::ostream &operator<<(std::ostream &out, - const GlobalRangeAndLocalRange &ranges) { +static std::ostream &operator<<(std::ostream &out, + const GlobalRangeAndLocalRange &ranges) { out << "GlobalRangeAndLocalRange{.global_range{" << ranges.global_range[0] << ", " << ranges.global_range[1] << "}, local_range{" << ranges.local_range[0] << ", " << ranges.local_range[1] << "}}"; @@ -481,7 +481,7 @@ TEST_P(Execution, Regression_68_Load16) { kts::Reference1D refOut = [=, &InBuffer](size_t x) -> unsigned char { - return InBuffer[x * 2] + InBuffer[x * 2 + 1]; + return InBuffer[x * 2] + InBuffer[(x * 2) + 1]; }; const size_t N = sizeof(InBuffer) / sizeof(cl_uchar); @@ -635,8 +635,8 @@ struct StrideAligned { } }; -std::stringstream &operator<<(std::stringstream &stream, - const StrideAligned &info) { +static std::stringstream &operator<<(std::stringstream &stream, + const StrideAligned &info) { stream << "{\n" << " global_size: " << info.global_size.x << ", " << info.global_size.y << ", " << info.global_size.z << ", " @@ -645,8 +645,8 @@ std::stringstream &operator<<(std::stringstream &stream, return stream; } -std::stringstream &operator<<(std::stringstream &stream, - const StrideMisaligned &info) { +static std::stringstream &operator<<(std::stringstream &stream, + const StrideMisaligned &info) { stream << "{\n" << " global_size: (" << info.global_size.x << ", " << info.global_size.y << ", " << info.global_size.z << ", " diff --git a/source/cl/test/UnitCL/source/ktst_regression_04.cpp b/source/cl/test/UnitCL/source/ktst_regression_04.cpp index 4a04a5529..8a5d577d3 100644 --- a/source/cl/test/UnitCL/source/ktst_regression_04.cpp +++ b/source/cl/test/UnitCL/source/ktst_regression_04.cpp @@ -178,7 +178,7 @@ TEST_P(Execution, Regression_80_Varying_Load) { int sum = n; if (meta == 0) { int mul = n * id; - const int div = mul / n + id; + const int div = (mul / n) + id; const int shl = div << 3; mul += shl; sum = mul << 3; @@ -206,7 +206,7 @@ TEST_P(Execution, Regression_81_Boscc_Nested_Loops1) { if (id % 2 == 0) { const bool cmp = n == 5; const int mul = n * id; - const int div = mul / n + id; + const int div = (mul / n) + id; const int shl = div << 3; const int x = mul + div + shl; for (int i = 0; i < n; ++i) { @@ -252,7 +252,7 @@ TEST_P(Execution, Regression_81_Boscc_Nested_Loops2) { int ret = 0; if (id < 16) { const int mul = n * id; - const int div = mul / n + id; + const int div = (mul / n) + id; const int shl = div << 3; const int x = mul + div + shl; for (int i = 0; i < n; ++i) { @@ -287,7 +287,7 @@ TEST_P(Execution, Regression_81_Boscc_Nested_Loops3) { if (id < n) { for (size_t i = 0; i < n; ++i) { const int mul = n * id; - const int div = mul / n + id; + const int div = (mul / n) + id; const int shl = div << 3; size_t x = mul + div + shl + i; for (; i < n; ++i) { @@ -354,7 +354,7 @@ TEST_P(Execution, Regression_83_Vecz_Lcssa) { int ret = 0; if (id % 2 == 0) { const int mul = n * id; - const int div = mul / n + id; + const int div = (mul / n) + id; const int shl = div << 3; const int x = mul + div + shl; for (int i = 0; i < n; ++i) { @@ -611,9 +611,8 @@ TEST_P(Execution, Regression_93_Ashr_Index_Underflow_1) { const cl_uint global = kts::N; const cl_uint read_local = 16; - auto refIn = kts::Reference1D([=](size_t id) { - return cl_int2{{kts::Ref_A(id), 0}}; - }); + auto refIn = kts::Reference1D( + [=](size_t id) { return cl_int2{{kts::Ref_A(id), 0}}; }); auto refOut = kts::Reference1D([=](size_t id) { return refIn(id >> 1).x; }); @@ -628,9 +627,8 @@ TEST_P(Execution, Regression_93_Ashr_Index_Underflow_2) { const cl_uint global = kts::N / 2; const cl_uint read_local = 16; - auto refIn = kts::Reference1D([=](size_t id) { - return cl_int2{{kts::Ref_A(id), 0}}; - }); + auto refIn = kts::Reference1D( + [=](size_t id) { return cl_int2{{kts::Ref_A(id), 0}}; }); auto refOut = kts::Reference1D( [=](size_t id) { return refIn((id * 3) >> 1).x; }); diff --git a/source/cl/test/UnitCL/source/ktst_regression_05.cpp b/source/cl/test/UnitCL/source/ktst_regression_05.cpp index 415d51f72..dc5547ad1 100644 --- a/source/cl/test/UnitCL/source/ktst_regression_05.cpp +++ b/source/cl/test/UnitCL/source/ktst_regression_05.cpp @@ -122,7 +122,7 @@ TEST_P(Execution, Regression_106_Varying_LCSSA_Phi) { if (hash & 1) { return static_cast(refIn(x)); } else { - return static_cast(hash); + return hash; } }; diff --git a/source/cl/test/UnitCL/source/ktst_spirv.cpp b/source/cl/test/UnitCL/source/ktst_spirv.cpp index 61021d585..810d38e63 100644 --- a/source/cl/test/UnitCL/source/ktst_spirv.cpp +++ b/source/cl/test/UnitCL/source/ktst_spirv.cpp @@ -95,12 +95,12 @@ struct Simple { }; // SPIR-V CTS tests copied into UnitCL to test regression on CA-1526 -std::ostream &operator<<(std::ostream &stream, const Simple &data) { +static std::ostream &operator<<(std::ostream &stream, const Simple &data) { stream << "{" << data.a << ", " << data.b << "}"; return stream; } -bool operator==(const Simple &lhs, const Simple &rhs) { +static bool operator==(const Simple &lhs, const Simple &rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; } diff --git a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_02.cpp b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_02.cpp index 29fa374bb..dc2dd0fa1 100644 --- a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_02.cpp +++ b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_02.cpp @@ -96,7 +96,7 @@ TEST_P(Execution, Task_02_09_Printf_Add) { TEST_P(Execution, Task_02_10_Modf_Builtin) { kts::Reference1D refIn = [](size_t x) { - return static_cast(x + (x % 2) * 0.5f); + return static_cast(x + ((x % 2) * 0.5f)); }; kts::Reference1D refFrac = [](size_t x) { return static_cast((x % 2) * 0.5f); diff --git a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_03.cpp b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_03.cpp index 22bbaf70f..06aa09ca7 100644 --- a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_03.cpp +++ b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_03.cpp @@ -74,7 +74,7 @@ TEST_P(Execution, Task_03_05_Distance4_Builtin) { const cl_float d1 = (v1.s[1] - v2.s[1]); const cl_float d2 = (v1.s[2] - v2.s[2]); const cl_float d3 = (v1.s[3] - v2.s[3]); - return std::sqrt(d0 * d0 + d1 * d1 + d2 * d2 + d3 * d3); + return std::sqrt((d0 * d0) + (d1 * d1) + (d2 * d2) + (d3 * d3)); }; AddInputBuffer(kts::N, refIn1); @@ -100,7 +100,7 @@ TEST_P(Execution, Task_03_07_Transpose4) { kts::Reference1D refOut = [](size_t x) { const cl_int ix = kts::Ref_Identity(x); const cl_int chunkID = ix % 4; - const cl_int base = (ix - chunkID) * 4 + chunkID; + const cl_int base = ((ix - chunkID) * 4) + chunkID; cl_int4 v; v.s[0] = kts::Ref_A(base + 0); v.s[1] = kts::Ref_A(base + 4); @@ -388,7 +388,7 @@ TEST_P(Execution, DISABLED_Task_03_28_Normalize4_Builtin) { TEST_P(Execution, Task_03_29_Modf4_Builtin) { kts::Reference1D refIn = [](size_t x) { - return static_cast(x + (x % 2) * 0.5f); + return static_cast(x + ((x % 2) * 0.5f)); }; kts::Reference1D refFrac = [](size_t x) { return static_cast((x % 2) * 0.5f); diff --git a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_07.cpp b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_07.cpp index 15805db0d..904b2d213 100644 --- a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_07.cpp +++ b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_07.cpp @@ -244,7 +244,7 @@ TEST_P(Execution, Task_07_12_Scalar_Masked_Load) { RunGeneric1D(N2, kts::localN); } -void TestScalarMaskedStore(Execution *e, bool isUniform = true) { +static void TestScalarMaskedStore(Execution *e, bool isUniform = true) { // Test with the first constant that exercises one path. const unsigned C1 = 1; const unsigned N1 = (unsigned)kts::N; @@ -323,7 +323,7 @@ TEST_P(Execution, Task_07_16_Normalize_Range_While) { TEST_P(Execution, Task_07_17_If_In_Loop) { kts::Reference1D refOut = [](size_t x) { cl_int sum = 0; - for (size_t i = 0; i <= (size_t)x; i++) { + for (size_t i = 0; i <= x; i++) { cl_int val; if (i & 1) { val = kts::Ref_B(x) * 2; @@ -413,7 +413,7 @@ TEST_P(Execution, Task_07_20_Sibling_Loops) { RunGeneric1D(kts::N); } -void TestHalfToFloat(Execution *e) { +static void TestHalfToFloat(Execution *e) { const size_t numSamples = 32; const cl_ushort inputs[numSamples] = { // Values required to reproduce #7163. @@ -445,7 +445,7 @@ void TestHalfToFloat(Execution *e) { 0x7f800000, 0xff800000, 0x7f802000, 0xff802000}; kts::Reference1D refIn = [=, &inputs](size_t x) { - return ((size_t)x < numSamples) ? inputs[x] : 0; + return x < numSamples ? inputs[x] : 0; }; kts::Reference1D refOut = [&outputs](size_t x, cl_uint r) { float result; diff --git a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_10.cpp b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_10.cpp index 5fa446ed3..15ffc8a2b 100644 --- a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_10.cpp +++ b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_10.cpp @@ -35,7 +35,7 @@ TEST_P(Execution, Task_10_01_Shuffle_Constant) { auto refIn2 = kts::BuildVec2Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { - return cl_int2{{kts::Ref_A(2 * x + 1), kts::Ref_A(4 * x + 2)}}; + return cl_int2{{kts::Ref_A((2 * x) + 1), kts::Ref_A((4 * x) + 2)}}; }; AddInputBuffer(kts::N, refIn1); @@ -54,7 +54,7 @@ TEST_P(Execution, Task_10_02_Shuffle_Runtime) { auto refIn2 = kts::BuildVec2Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { - return cl_int2{{kts::Ref_A(2 * x + 1), kts::Ref_A(4 * x + 2)}}; + return cl_int2{{kts::Ref_A((2 * x) + 1), kts::Ref_A((4 * x) + 2)}}; }; AddInputBuffer(kts::N, refIn1); @@ -254,9 +254,9 @@ TEST_P(Execution, Task_10_08_InsertElement_Constant_Index) { auto refIn = kts::BuildVec4Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { cl_int a = kts::Ref_A(4 * x); - cl_int b = kts::Ref_A(4 * x + 1); + cl_int b = kts::Ref_A((4 * x) + 1); cl_int c = 42; - cl_int d = kts::Ref_A(4 * x + 3); + cl_int d = kts::Ref_A((4 * x) + 3); return cl_int4{{a, b, c, d}}; }; AddInputBuffer(kts::N, refIn); @@ -271,9 +271,9 @@ TEST_P(Execution, Task_10_09_InsertElement_Runtime_Index) { auto refIn = kts::BuildVec4Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { cl_int a = (x % 4 == 0) ? 42 : kts::Ref_A(4 * x); - cl_int b = (x % 4 == 1) ? 42 : kts::Ref_A(4 * x + 1); - cl_int c = (x % 4 == 2) ? 42 : kts::Ref_A(4 * x + 2); - cl_int d = (x % 4 == 3) ? 42 : kts::Ref_A(4 * x + 3); + cl_int b = (x % 4 == 1) ? 42 : kts::Ref_A((4 * x) + 1); + cl_int c = (x % 4 == 2) ? 42 : kts::Ref_A((4 * x) + 2); + cl_int d = (x % 4 == 3) ? 42 : kts::Ref_A((4 * x) + 3); return cl_int4{{a, b, c, d}}; }; AddInputBuffer(kts::N, refIn); diff --git a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_12.cpp b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_12.cpp index 9967c8f21..2211021cf 100644 --- a/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_12.cpp +++ b/source/cl/test/UnitCL/source/ktst_vecz_tasks_task_12.cpp @@ -40,7 +40,7 @@ TEST_P(Execution, Task_12_01_Interleaved_Load_4) { }; kts::Reference1D refOut = [=, &InBuffer](size_t x) -> int { - return InBuffer[x * 2 + 1] - InBuffer[x * 2]; + return InBuffer[(x * 2) + 1] - InBuffer[x * 2]; }; const size_t N = sizeof(InBuffer) / sizeof(cl_int); @@ -70,8 +70,8 @@ TEST_P(Execution, Task_12_02_Interleaved_Load_5) { }; kts::Reference1D refOut = [=, &InBuffer](size_t x) -> int { - return InBuffer[x * 2] + InBuffer[x * 2 + 1] + InBuffer[x * 2 + 2] + - InBuffer[x * 2 + 3]; + return InBuffer[x * 2] + InBuffer[(x * 2) + 1] + InBuffer[(x * 2) + 2] + + InBuffer[(x * 2) + 3]; }; const size_t N = sizeof(InBuffer) / sizeof(cl_int); @@ -101,7 +101,7 @@ TEST_P(Execution, Task_12_03_Interleaved_Load_6) { }; kts::Reference1D refOut = [=, &InBuffer](size_t x) -> int { - return (InBuffer[x * 2 + 3] << 1) - InBuffer[x * 2 + 2]; + return (InBuffer[(x * 2) + 3] << 1) - InBuffer[(x * 2) + 2]; }; const size_t N = sizeof(InBuffer) / sizeof(cl_int); diff --git a/source/cl/test/UnitCL/source/macros.cpp b/source/cl/test/UnitCL/source/macros.cpp index b18002e50..e567b6976 100644 --- a/source/cl/test/UnitCL/source/macros.cpp +++ b/source/cl/test/UnitCL/source/macros.cpp @@ -22,7 +22,8 @@ struct MacroTestParams { const ucl::Version minimum_version; }; -std::ostream &operator<<(std::ostream &out, const MacroTestParams ¶ms) { +static std::ostream &operator<<(std::ostream &out, + const MacroTestParams ¶ms) { out << "MacroTestParams{.condition{\"" << params.condition << "\"}, .options{\"" << params.options << "\"}, .minimum_version{" << params.minimum_version << "}}"; @@ -67,7 +68,8 @@ struct MacrosTest : ucl::CommandQueueTest, buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY, 1, nullptr, &status); ASSERT_SUCCESS(status); - ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), &buffer)); + ASSERT_SUCCESS(clSetKernelArg(kernel, 0, sizeof(cl_mem), + static_cast(&buffer))); } void TearDown() override { diff --git a/source/cl/test/UnitCL/source/main.cpp b/source/cl/test/UnitCL/source/main.cpp index deb557f7d..fe15872b0 100644 --- a/source/cl/test/UnitCL/source/main.cpp +++ b/source/cl/test/UnitCL/source/main.cpp @@ -25,7 +25,7 @@ // able to refer to it at all. Still, it is easier than reinventing the wheel. namespace testing::internal { enum class GTestColor { kDefault, kRed, kGreen, kYellow }; -void ColoredPrintf(GTestColor color, const char *fmt, ...); +extern void ColoredPrintf(GTestColor color, const char *fmt, ...); } // namespace testing::internal #ifdef _WIN32 diff --git a/source/cl/test/UnitCL/source/printfBuiltin.cpp b/source/cl/test/UnitCL/source/printfBuiltin.cpp index 4ae36a24c..9687281ea 100644 --- a/source/cl/test/UnitCL/source/printfBuiltin.cpp +++ b/source/cl/test/UnitCL/source/printfBuiltin.cpp @@ -92,7 +92,7 @@ class printfBuiltinValidTest : public printfBuiltinTest {}; class printfBuiltinInvalidTest : public printfBuiltinTest {}; -const char *valid_kernels[] = { +static const char *valid_kernels[] = { "void kernel foo(global int * a, global int * b)" "{" " *a = printf(\"0x%08x\\n\", *b);" @@ -124,7 +124,7 @@ const char *valid_kernels[] = { "}\n", }; -const char *invalid_kernels[] = { +static const char *invalid_kernels[] = { // 'l' length modifier must not be used with 'c'. "void kernel foo(global int * a, global int * b)" "{\n" diff --git a/source/cl/test/UnitCL/source/sub_groups.cpp b/source/cl/test/UnitCL/source/sub_groups.cpp index 963e31f0d..49ba615dc 100644 --- a/source/cl/test/UnitCL/source/sub_groups.cpp +++ b/source/cl/test/UnitCL/source/sub_groups.cpp @@ -274,7 +274,7 @@ TEST_P(SubGroupTest, Sub_Group_07_Sub_Group_All_Builtin) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -334,7 +334,7 @@ TEST_P(SubGroupTest, Sub_Group_08_Sub_Group_Any_Builtin) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -433,15 +433,16 @@ TEST_P(SubGroupTest, Sub_Group_09_Sub_Group_Broadcast_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data, &sub_group_local_ids](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const auto sub_group_local_id = sub_group_local_ids[sub_group_id]; - const auto expected = input_data[sub_group[sub_group_local_id]]; - return result == expected; - }; + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data, &sub_group_local_ids]( + size_t gid, cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto sub_group_local_id = sub_group_local_ids[sub_group_id]; + const auto expected = input_data[sub_group[sub_group_local_id]]; + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); std::generate(std::begin(sub_group_local_ids), std::end(sub_group_local_ids), @@ -517,15 +518,16 @@ TEST_P(SubGroupTest, Sub_Group_09_Sub_Group_Broadcast_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data, &sub_group_local_ids](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const auto sub_group_local_id = sub_group_local_ids[sub_group_id]; - const auto expected = input_data[sub_group[sub_group_local_id]]; - return result == expected; - }; + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data, &sub_group_local_ids]( + size_t gid, cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto sub_group_local_id = sub_group_local_ids[sub_group_id]; + const auto expected = input_data[sub_group[sub_group_local_id]]; + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); std::generate(std::begin(sub_group_local_ids), std::end(sub_group_local_ids), @@ -605,7 +607,8 @@ TEST_P(SubGroupTest, Sub_Group_09_Sub_Group_Broadcast_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, &sub_group_local_ids, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const auto sub_group_local_id = sub_group_local_ids[sub_group_id]; const auto expected = input_data[sub_group[sub_group_local_id]]; return kts::ucl::ULPValidator(this->device) @@ -647,7 +650,7 @@ TEST_P(SubGroupTest, Sub_Group_10_Sub_Group_Reduce_Add_Uint) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -701,7 +704,7 @@ TEST_P(SubGroupTest, Sub_Group_10_Sub_Group_Reduce_Add_Int) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -754,7 +757,7 @@ TEST_P(SubGroupTest, Sub_Group_10_Sub_Group_Reduce_Add_Float) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -798,7 +801,7 @@ TEST_P(SubGroupTest, Sub_Group_11_Sub_Group_Reduce_Min_Uint) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -842,7 +845,7 @@ TEST_P(SubGroupTest, Sub_Group_11_Sub_Group_Reduce_Min_Int) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -886,7 +889,7 @@ TEST_P(SubGroupTest, Sub_Group_11_Sub_Group_Reduce_Min_Float) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -950,7 +953,7 @@ TEST_P(SubGroupTest, Sub_Group_12_Sub_Group_Reduce_Max_Uint) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -994,7 +997,7 @@ TEST_P(SubGroupTest, Sub_Group_12_Sub_Group_Reduce_Max_Int) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -1038,7 +1041,7 @@ TEST_P(SubGroupTest, Sub_Group_12_Sub_Group_Reduce_Max_Float) { // There is an output buffer for each sub-group in each work-group. The last // sub-group may be smaller than the others. const auto output_buffer_size = - global_size / sub_group_max_size + !!(global_size % sub_group_max_size); + (global_size / sub_group_max_size) + !!(global_size % sub_group_max_size); std::vector input_data(global_size); @@ -1122,21 +1125,22 @@ TEST_P(SubGroupTest, Sub_Group_13_Sub_Group_Scan_Exclusive_Add_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = 0; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected += input_data[sub_group[i]]; - } - return result == expected; - }; + cl_uint expected = 0; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected += input_data[sub_group[i]]; + } + return result == expected; + }; // A random selection of values. ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); @@ -1200,21 +1204,22 @@ TEST_P(SubGroupTest, Sub_Group_13_Sub_Group_Scan_Exclusive_Add_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = 0; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected += input_data[sub_group[i]]; - } - return result == expected; - }; + cl_int expected = 0; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected += input_data[sub_group[i]]; + } + return result == expected; + }; // A random selection of values being careful to avoid the possibility of // overflow. @@ -1284,7 +1289,8 @@ TEST_P(SubGroupTest, Sub_Group_13_Sub_Group_Scan_Exclusive_Add_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); @@ -1350,21 +1356,22 @@ TEST_P(SubGroupTest, Sub_Group_14_Sub_Group_Scan_Exclusive_Min_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = CL_UINT_MAX; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected = std::min(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_uint expected = CL_UINT_MAX; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected = std::min(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -1418,21 +1425,22 @@ TEST_P(SubGroupTest, Sub_Group_14_Sub_Group_Scan_Exclusive_Min_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = CL_INT_MAX; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected = std::min(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_int expected = CL_INT_MAX; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected = std::min(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -1490,7 +1498,8 @@ TEST_P(SubGroupTest, Sub_Group_14_Sub_Group_Scan_Exclusive_Min_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); @@ -1557,21 +1566,22 @@ TEST_P(SubGroupTest, Sub_Group_15_Sub_Group_Scan_Exclusive_Max_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = 0; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected = std::max(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_uint expected = 0; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected = std::max(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -1625,21 +1635,22 @@ TEST_P(SubGroupTest, Sub_Group_15_Sub_Group_Scan_Exclusive_Max_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = CL_INT_MIN; - for (unsigned i = 0; i < sub_group_local_id; ++i) { - expected = std::max(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_int expected = CL_INT_MIN; + for (unsigned i = 0; i < sub_group_local_id; ++i) { + expected = std::max(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -1697,7 +1708,8 @@ TEST_P(SubGroupTest, Sub_Group_15_Sub_Group_Scan_Exclusive_Max_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); @@ -1764,21 +1776,22 @@ TEST_P(SubGroupTest, Sub_Group_16_Sub_Group_Scan_Inclusive_Add_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = 0; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected += input_data[sub_group[i]]; - } - return result == expected; - }; + cl_uint expected = 0; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected += input_data[sub_group[i]]; + } + return result == expected; + }; // A random selection of values. ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); @@ -1842,21 +1855,22 @@ TEST_P(SubGroupTest, Sub_Group_16_Sub_Group_Scan_Inclusive_Add_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = 0; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected += input_data[sub_group[i]]; - } - return result == expected; - }; + cl_int expected = 0; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected += input_data[sub_group[i]]; + } + return result == expected; + }; // A random selection of values being careful to avoid the possibility of // overflow. @@ -1926,7 +1940,8 @@ TEST_P(SubGroupTest, Sub_Group_16_Sub_Group_Scan_Inclusive_Add_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); @@ -1991,21 +2006,22 @@ TEST_P(SubGroupTest, Sub_Group_17_Sub_Group_Scan_Inclusive_Min_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = CL_UINT_MAX; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected = std::min(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_uint expected = CL_UINT_MAX; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected = std::min(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -2059,21 +2075,22 @@ TEST_P(SubGroupTest, Sub_Group_17_Sub_Group_Scan_Inclusive_Min_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = CL_INT_MAX; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected = std::min(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_int expected = CL_INT_MAX; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected = std::min(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -2131,7 +2148,8 @@ TEST_P(SubGroupTest, Sub_Group_17_Sub_Group_Scan_Inclusive_Min_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); @@ -2197,21 +2215,22 @@ TEST_P(SubGroupTest, Sub_Group_18_Sub_Group_Scan_Inclusive_Max_Uint) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_uint result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_uint result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_uint expected = 0; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected = std::max(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_uint expected = 0; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected = std::max(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -2265,21 +2284,22 @@ TEST_P(SubGroupTest, Sub_Group_18_Sub_Group_Scan_Inclusive_Max_Int) { sub_group_global_id_global_ids_map); }; - kts::Reference1D output_ref_b = - [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, - &input_data](size_t gid, cl_int result) { - const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; - const unsigned sub_group_local_id = std::distance( - std::begin(sub_group), - std::find(std::begin(sub_group), std::end(sub_group), gid)); + kts::Reference1D output_ref_b = [&sub_group_global_id_global_ids_map, + &global_id_sub_group_global_id_map, + &input_data](size_t gid, + cl_int result) { + const auto sub_group_id = global_id_sub_group_global_id_map[gid]; + const auto &sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const unsigned sub_group_local_id = std::distance( + std::begin(sub_group), + std::find(std::begin(sub_group), std::end(sub_group), gid)); - cl_int expected = CL_INT_MIN; - for (unsigned i = 0; i <= sub_group_local_id; ++i) { - expected = std::max(expected, input_data[sub_group[i]]); - } - return result == expected; - }; + cl_int expected = CL_INT_MIN; + for (unsigned i = 0; i <= sub_group_local_id; ++i) { + expected = std::max(expected, input_data[sub_group[i]]); + } + return result == expected; + }; ucl::Environment::instance->GetInputGenerator().GenerateData(input_data); AddInputBuffer(global_size, input_ref); @@ -2337,7 +2357,8 @@ TEST_P(SubGroupTest, Sub_Group_18_Sub_Group_Scan_Inclusive_Max_Float) { [&sub_group_global_id_global_ids_map, &global_id_sub_group_global_id_map, &input_data, this](size_t gid, cl_float result) { const auto sub_group_id = global_id_sub_group_global_id_map[gid]; - const auto sub_group = sub_group_global_id_global_ids_map[sub_group_id]; + const auto &sub_group = + sub_group_global_id_global_ids_map[sub_group_id]; const unsigned sub_group_local_id = std::distance( std::begin(sub_group), std::find(std::begin(sub_group), std::end(sub_group), gid)); diff --git a/source/cl/test/UnitCL/source/ucl/fixtures.cpp b/source/cl/test/UnitCL/source/ucl/fixtures.cpp index 2d7a8bae8..b4bd0cb2f 100644 --- a/source/cl/test/UnitCL/source/ucl/fixtures.cpp +++ b/source/cl/test/UnitCL/source/ucl/fixtures.cpp @@ -100,8 +100,8 @@ namespace { template T getDeviceInfo(cl_device_id device, cl_device_info info) { T value; - if (auto error = - clGetDeviceInfo(device, info, sizeof(value), &value, nullptr)) { + if (auto error = clGetDeviceInfo(device, info, sizeof(value), + static_cast(&value), nullptr)) { UCL_ABORT("clGetDeviceInfo failed: %d", error); } return value; diff --git a/source/cl/test/UnitCL/source/work_group_collective_functions.cpp b/source/cl/test/UnitCL/source/work_group_collective_functions.cpp index 442e757e2..4f06e3528 100644 --- a/source/cl/test/UnitCL/source/work_group_collective_functions.cpp +++ b/source/cl/test/UnitCL/source/work_group_collective_functions.cpp @@ -104,7 +104,7 @@ struct NDRange { operator const size_t *() const { return &array[0]; } }; -inline std::string to_string(const NDRange &ndrange) { +inline static std::string to_string(const NDRange &ndrange) { return std::to_string(ndrange.x()) + 'x' + std::to_string(ndrange.y()) + 'x' + std::to_string(ndrange.z()); } @@ -122,8 +122,8 @@ static std::array globalLinearIdToGlobalId(size_t global_linear_id, static size_t globalIdToGlobalLinearId(std::array global_ids, size_t global_size_x, size_t global_size_y) { - return global_ids[0] + global_size_x * global_ids[1] + - global_size_x * global_size_y * global_ids[2]; + return global_ids[0] + (global_size_x * global_ids[1]) + + (global_size_x * global_size_y * global_ids[2]); } struct ReductionRange { @@ -347,7 +347,7 @@ struct WorkGroupCollectiveBroadcast1D local_size_x, &broadcast_ids]( size_t global_linear_id, T value) { const auto work_group_linear_id = global_linear_id / work_group_size; - const auto broadcast_id = work_group_linear_id * local_size_x + + const auto broadcast_id = (work_group_linear_id * local_size_x) + broadcast_ids[work_group_linear_id]; return value == input_data[broadcast_id]; }; @@ -421,12 +421,12 @@ struct WorkGroupCollectiveBroadcast2D const auto work_group_id_y = global_ids[1] / local_size_y; const auto work_group_linear_id = - work_group_id_x + work_group_id_y * global_sizes[0] / local_size_x; + work_group_id_x + (work_group_id_y * global_sizes[0] / local_size_x); - const auto broadcast_x_id = local_size_x * work_group_id_x + + const auto broadcast_x_id = (local_size_x * work_group_id_x) + broadcast_x_ids[work_group_linear_id]; - const auto broadcast_y_id = local_size_y * work_group_id_y + + const auto broadcast_y_id = (local_size_y * work_group_id_y) + broadcast_y_ids[work_group_linear_id]; const auto broadcast_linear_id = @@ -513,17 +513,17 @@ struct WorkGroupCollectiveBroadcast3D const auto work_group_id_z = global_ids[2] / local_size_z; const auto work_group_linear_id = - work_group_id_x + work_group_id_y * global_sizes[0] / local_size_x + - work_group_id_z * global_sizes[0] / local_size_x * global_sizes[1] / - local_size_y; + work_group_id_x + (work_group_id_y * global_sizes[0] / local_size_x) + + (work_group_id_z * global_sizes[0] / local_size_x * global_sizes[1] / + local_size_y); - const auto broadcast_x_id = local_size_x * work_group_id_x + + const auto broadcast_x_id = (local_size_x * work_group_id_x) + broadcast_x_ids[work_group_linear_id]; - const auto broadcast_y_id = local_size_y * work_group_id_y + + const auto broadcast_y_id = (local_size_y * work_group_id_y) + broadcast_y_ids[work_group_linear_id]; - const auto broadcast_z_id = local_size_z * work_group_id_z + + const auto broadcast_z_id = (local_size_z * work_group_id_z) + broadcast_z_ids[work_group_linear_id]; const auto broadcast_linear_id = globalIdToGlobalLinearId( @@ -612,10 +612,11 @@ struct WorkGroupCollectiveScanReductionTestBase using WorkGroupCollectiveReductions = WorkGroupCollectiveScanReductionTestBase; template -bool reduceBinOpRefFn(size_t global_linear_id, T result, - const std::vector &input_data, - const NDRange &global_sizes, const NDRange &local_sizes, - T initial_val, const std::function &reduce_fn) { +static bool reduceBinOpRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes, T initial_val, + const std::function &reduce_fn) { T expected = initial_val; const auto range = getReductionRange(global_linear_id, global_sizes.array, local_sizes.array); @@ -633,9 +634,10 @@ bool reduceBinOpRefFn(size_t global_linear_id, T result, } template -bool reduceAddRefFn(size_t global_linear_id, T result, - const std::vector &input_data, - const NDRange &global_sizes, const NDRange &local_sizes) { +static bool reduceAddRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &reduce_fn = [](T a, T b) { return a + b; }; return reduceBinOpRefFn(global_linear_id, result, input_data, global_sizes, local_sizes, T{0}, reduce_fn); @@ -659,9 +661,10 @@ TEST_P(WorkGroupCollectiveReductions, } template -bool reduceMinRefFn(size_t global_linear_id, T result, - const std::vector &input_data, - const NDRange &global_sizes, const NDRange &local_sizes) { +static bool reduceMinRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &reduce_fn = [](T a, T b) { return std::min(a, b); }; @@ -688,9 +691,10 @@ TEST_P(WorkGroupCollectiveReductions, } template -bool reduceMaxRefFn(size_t global_linear_id, T result, - const std::vector &input_data, - const NDRange &global_sizes, const NDRange &local_sizes) { +static bool reduceMaxRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &reduce_fn = [](T a, T b) { return std::max(a, b); }; @@ -719,10 +723,11 @@ TEST_P(WorkGroupCollectiveReductions, using WorkGroupCollectiveScans = WorkGroupCollectiveScanReductionTestBase; template -bool scanBinOpRefFn(size_t global_linear_id, T result, - const std::vector &input_data, - const NDRange &global_sizes, const NDRange &local_sizes, - T initial_val, const std::function &scan_fn) { +static bool scanBinOpRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes, T initial_val, + const std::function &scan_fn) { T expected = initial_val; const auto range = @@ -746,9 +751,10 @@ bool scanBinOpRefFn(size_t global_linear_id, T result, } template -bool scanAddRefFn(size_t global_linear_id, T result, - const std::vector &input_data, const NDRange &global_sizes, - const NDRange &local_sizes) { +static bool scanAddRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &scan_fn = [](T a, T b) { return a + b; }; return scanBinOpRefFn(global_linear_id, result, input_data, global_sizes, local_sizes, T{0}, @@ -756,9 +762,10 @@ bool scanAddRefFn(size_t global_linear_id, T result, } template -bool scanMinRefFn(size_t global_linear_id, T result, - const std::vector &input_data, const NDRange &global_sizes, - const NDRange &local_sizes) { +static bool scanMinRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &scan_fn = [](T a, T b) { return std::min(a, b); }; @@ -768,9 +775,10 @@ bool scanMinRefFn(size_t global_linear_id, T result, } template -bool scanMaxRefFn(size_t global_linear_id, T result, - const std::vector &input_data, const NDRange &global_sizes, - const NDRange &local_sizes) { +static bool scanMaxRefFn(size_t global_linear_id, T result, + const std::vector &input_data, + const NDRange &global_sizes, + const NDRange &local_sizes) { const std::function &scan_fn = [](T a, T b) { return std::max(a, b); }; diff --git a/source/cl/tools/clc/clc.cpp b/source/cl/tools/clc/clc.cpp index 87eaf2647..b717a7174 100644 --- a/source/cl/tools/clc/clc.cpp +++ b/source/cl/tools/clc/clc.cpp @@ -65,11 +65,11 @@ int main(int argc, char **argv) { namespace clc { -void mux_message(const char *message, const void *, size_t) { +static void mux_message(const char *message, const void *, size_t) { (void)std::fprintf(stderr, "%s", message); } -std::map cl_error_code_to_name_map = { +static std::map cl_error_code_to_name_map = { {0, "CL_SUCCESS"}, {-1, "CL_DEVICE_NOT_FOUND"}, {-2, "CL_DEVICE_NOT_AVAILABLE"}, @@ -133,11 +133,13 @@ std::map cl_error_code_to_name_map = { {-70, "CL_INVALID_DEVICE_QUEUE"}, }; -bool matchSubstring(cargo::string_view big_string, cargo::string_view filter) { +static bool matchSubstring(cargo::string_view big_string, + cargo::string_view filter) { return big_string.find(filter) != cargo::string_view::npos; } -result printMuxCompilers(cargo::array_view compilers) { +static result printMuxCompilers( + cargo::array_view compilers) { for (cl_uint i = 0; i < compilers.size(); i++) { (void)std::fprintf(stderr, "device %u: %s\n", i + 1, compilers[i]->device_info->device_name); @@ -159,7 +161,7 @@ driver::driver() #define CL_STD_CHOICES "{CL1.1,CL1.2,CL3.0}\n " -const char *CLC_USAGE = +static const char *CLC_USAGE = R"(usage: %s [options] [--] [] An OpenCL C 1.2 and SPIR-V 1.0 compiler to generate machine code for the @@ -332,7 +334,7 @@ result driver::parseArguments(int argc, char **argv) { cargo::string_view help_view, bool takes_value) : takes_value(takes_value), name(name_view.data(), name_view.size()), - help(help_view.data(), help_view.size()){}; + help(help_view.data(), help_view.size()) {}; }; std::map> @@ -513,7 +515,7 @@ result driver::setupContext() { return result::success; } -result ReadWholeFile(std::istream &fp, std::vector &output) { +static result ReadWholeFile(std::istream &fp, std::vector &output) { fp.seekg(0, std::ios_base::end); if (!fp.fail()) { @@ -713,7 +715,7 @@ result driver::saveBinary() { if (fp == nullptr) { fp = fopen(generated_output_file.c_str(), "wb"); if (fp == nullptr) { - (void)perror("error: Could not open output file"); + perror("error: Could not open output file"); return result::failure; } owns_fp = true; @@ -726,8 +728,7 @@ result driver::saveBinary() { write_error |= fflush(fp); } if (write_error) { - (void)perror( - "error: Could not write all of the binary to the output file"); + perror("error: Could not write all of the binary to the output file"); return result::failure; } } diff --git a/source/cl/tools/oclc/oclc.cpp b/source/cl/tools/oclc/oclc.cpp index 17b7db025..231bcbbb0 100644 --- a/source/cl/tools/oclc/oclc.cpp +++ b/source/cl/tools/oclc/oclc.cpp @@ -402,9 +402,7 @@ bool oclc::Driver::ParseSizeInfo(const std::string &argName, argName.c_str()); const cl_uint current_work_dim = (cl_uint)repeatVec[count].size(); - if (current_work_dim > work_dim_) { - work_dim_ = current_work_dim; - } + work_dim_ = std::max(current_work_dim, work_dim_); if (argName == "global") { global_work_size_.resize(repeatCount); @@ -657,7 +655,7 @@ template T oclc::Driver::NextUniform(T min, T max) { const double dScale = (1 + max - min) / (double)(engine_.max() - engine_.min()); - return (engine_() - engine_.min()) * dScale + min; + return ((engine_() - engine_.min()) * dScale) + min; } bool oclc::Driver::ExpandRandVec(std::vector &vec) { @@ -701,7 +699,7 @@ std::vector oclc::Driver::CreateRange(T a, T b, T stride) { // not reliable. The loops therefore run until (`i` - half of the stride), // reaches `b`, as this value will be well past `b`, and the small floating // point inaccuracies won't matter. - T error = std::is_same::value ? 0.5 * stride : 0; + T error = std::is_same_v ? 0.5 * stride : 0; if (b > a && stride > 0.0) { for (T i = a; i - error <= b; i += stride) { vec.push_back(std::to_string(i)); @@ -817,7 +815,7 @@ const char *oclc::Driver::VerifyRepeat(const char *arg, for (size_t itr = 0; itr < count; ++itr) { for (size_t sublist_itr = 0; sublist_itr < stride; ++sublist_itr) { - vec[itr * stride + sublist_itr] = subList[sublist_itr]; + vec[(itr * stride) + sublist_itr] = subList[sublist_itr]; } } @@ -1165,8 +1163,8 @@ bool oclc::Driver::BuildProgram() { // Detect the source file type. SourceFileType source_file_type = SourceFileType::OpenCL_C; - const static char spir_magic[] = {'B', 'C', (char)0xC0, (char)0xDE}; - const static char spirv_magic[] = {(char)0x03, (char)0x02, (char)0x23, + static const char spir_magic[] = {'B', 'C', (char)0xC0, (char)0xDE}; + static const char spirv_magic[] = {(char)0x03, (char)0x02, (char)0x23, (char)0x07}; if (source_.size() > 4) { if (0 == memcmp(source_.data(), spir_magic, sizeof(spir_magic))) { @@ -1289,7 +1287,7 @@ bool oclc::Driver::GetProgramBinary() { OCLC_CHECK_CL(err, "Getting the number of binaries failed"); binaries.resize(num_binaries / sizeof(const char *)); err = clGetProgramInfo(program_, CL_PROGRAM_BINARIES, num_binaries, - binary_refs.data(), nullptr); + static_cast(binary_refs.data()), nullptr); OCLC_CHECK_CL(err, "Getting the binaries failed"); binary_ = binaries[0]; return oclc::success; @@ -1314,8 +1312,7 @@ std::string oclc::Driver::BufferToString(const unsigned char *buffer, size_t n, stringVal += (std::to_string(static_cast(charBuffer[i])) + ","); } } else if (dataType == "uchar") { - const unsigned char *ucharBuffer = - reinterpret_cast(buffer); + const unsigned char *ucharBuffer = buffer; for (size_t i = 0; i < n; ++i) { stringVal += (std::to_string(static_cast(ucharBuffer[i])) + ","); @@ -1821,7 +1818,8 @@ bool oclc::Driver::EnqueueKernel() { buffer_map.emplace(arg_name, std::pair(buffer, type_name)); - err = clSetKernelArg(kernel, i, sizeof(cl_mem), &buffer); + err = clSetKernelArg(kernel, i, sizeof(cl_mem), + static_cast(&buffer)); } } else if (is_image1d || is_image2d || is_image3d) { cl_mem image; @@ -1880,7 +1878,8 @@ bool oclc::Driver::EnqueueKernel() { std::pair>( arg_name, std::pair(image, typeName))); } - err = clSetKernelArg(kernel, i, sizeof(cl_mem), &image); + err = clSetKernelArg(kernel, i, sizeof(cl_mem), + static_cast(&image)); } else if (is_sampler) { cl_sampler sampler; if (input != kernel_arg_map_.end()) { @@ -1909,7 +1908,8 @@ bool oclc::Driver::EnqueueKernel() { CL_FILTER_NEAREST, &err); } OCLC_CHECK_CL(err, "Creating sampler failed"); - err = clSetKernelArg(kernel, i, sizeof(cl_sampler), &sampler); + err = clSetKernelArg(kernel, i, sizeof(cl_sampler), + static_cast(&sampler)); if (CL_SUCCESS == err) { samplers.push_back(sampler); } diff --git a/source/vk/examples/VectorAddition/source/main.c b/source/vk/examples/VectorAddition/source/main.c index d76766b76..f3470e4d5 100644 --- a/source/vk/examples/VectorAddition/source/main.c +++ b/source/vk/examples/VectorAddition/source/main.c @@ -111,7 +111,7 @@ uint32_t getComputeQueueFamilyIndex(VkPhysicalDevice device) { vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_properties_count, 0); // Request all queue families - VkQueueFamilyProperties* queue_properties = (VkQueueFamilyProperties*)malloc( + VkQueueFamilyProperties *queue_properties = (VkQueueFamilyProperties *)malloc( sizeof(VkQueueFamilyProperties) * queue_properties_count); vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_properties_count, @@ -137,8 +137,8 @@ uint32_t getComputeQueueFamilyIndex(VkPhysicalDevice device) { // Given a VkInstance this function finds a vkPhysicalDevice and VkDevice // corresponding to Codeplay's CPU target. -void createVkDevice(VkInstance instance, VkDevice* device, - VkPhysicalDevice* physical_device) { +void createVkDevice(VkInstance instance, VkDevice *device, + VkPhysicalDevice *physical_device) { // Retrieve list of physical devices uint32_t num_devices = 0; IS_VK_SUCCESS(vkEnumeratePhysicalDevices(instance, &num_devices, 0)); @@ -148,13 +148,13 @@ void createVkDevice(VkInstance instance, VkDevice* device, exit(1); } - VkPhysicalDevice* phys_devices = - (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * num_devices); + VkPhysicalDevice *phys_devices = + (VkPhysicalDevice *)malloc(sizeof(VkPhysicalDevice) * num_devices); IS_VK_SUCCESS( vkEnumeratePhysicalDevices(instance, &num_devices, phys_devices)); // Find Codeplay CPU device - VkPhysicalDevice* codeplay_cpu_device = NULL; + VkPhysicalDevice *codeplay_cpu_device = NULL; for (uint32_t i = 0; i < num_devices; ++i) { VkPhysicalDevice phys_device = phys_devices[i]; @@ -212,7 +212,7 @@ void createVkDevice(VkInstance instance, VkDevice* device, IS_VK_SUCCESS( vkCreateDevice(*physical_device, &device_create_info, 0, device)); - free(phys_devices); + free((void *)phys_devices); } // Loads our shader, sets up compute pipeline and command buffer, before @@ -438,7 +438,7 @@ void buildAndRunShader(VkDevice device, uint32_t compute_queue_family, IS_VK_SUCCESS(vkQueueWaitIdle(queue)); // Cleanup - vkDestroyDescriptorSetLayout(device, descriptor_set_layout, NULL); + vkDestroyDescriptorSetLayout(device, descriptor_set_layout, NULL); vkDestroyShaderModule(device, shader_module, NULL); vkDestroyPipeline(device, pipeline, NULL); vkDestroyPipelineLayout(device, pipeline_layout, NULL); @@ -475,12 +475,14 @@ int main(void) { printf(" * Allocated %" PRIu64 " bytes of device memory\n", memory_size); // Map input buffers to host so that we can initialize them - int32_t* mapped_ptr; + void *mapped_ptr_void; + int32_t *mapped_ptr; // Input buffer 1 will reside in the first `buffer_size` bytes of memory, and // each buffer element is initialized to it's index. IS_VK_SUCCESS( - vkMapMemory(device, memory, 0, buffer_size, 0, (void*)&mapped_ptr)); + vkMapMemory(device, memory, 0, buffer_size, 0, &mapped_ptr_void)); + mapped_ptr = mapped_ptr_void; for (int32_t i = 0; i < NUM_WORK_ITEMS; ++i) { mapped_ptr[i] = i; } @@ -489,7 +491,8 @@ int main(void) { // Input buffer 2 will be located at offset `buffer_size` in memory, and // each buffer element is initialized to it's index plus one. IS_VK_SUCCESS(vkMapMemory(device, memory, buffer_size, buffer_size, 0, - (void*)&mapped_ptr)); + &mapped_ptr_void)); + mapped_ptr = mapped_ptr_void; for (int32_t i = 0; i < NUM_WORK_ITEMS; ++i) { mapped_ptr[i] = i + 1; } @@ -533,7 +536,7 @@ int main(void) { // Map our output buffer back to host memory IS_VK_SUCCESS(vkMapMemory(device, memory, 2 * buffer_size, buffer_size, 0, - (void*)&mapped_ptr)); + &mapped_ptr_void)); // Verify our results for (int32_t i = 0; i < NUM_WORK_ITEMS; ++i) { diff --git a/source/vk/include/vk/allocator.h b/source/vk/include/vk/allocator.h index 1be19af0d..608b2840b 100644 --- a/source/vk/include/vk/allocator.h +++ b/source/vk/include/vk/allocator.h @@ -233,7 +233,7 @@ class cargo_allocator { /// /// @param allocation Allocation to deallocate. void free(pointer allocation) { - pAllocator->pfnFree(pAllocator->pUserData, allocation); + pAllocator->pfnFree(pAllocator->pUserData, static_cast(allocation)); } /// @brief Allocate space for and construct an object. diff --git a/source/vk/include/vk/icd.h b/source/vk/include/vk/icd.h index 4a7dd4dde..ddaeb5313 100644 --- a/source/vk/include/vk/icd.h +++ b/source/vk/include/vk/icd.h @@ -22,6 +22,13 @@ template struct icd_t { uintptr_t magic = 0x01CDC0DE; + + friend T; + + private: + icd_t() = default; + icd_t(const icd_t &) = default; + icd_t(icd_t &&) = default; }; #endif diff --git a/source/vk/source/allocator.cpp b/source/vk/source/allocator.cpp index e1b8d3a39..392ed61bc 100644 --- a/source/vk/source/allocator.cpp +++ b/source/vk/source/allocator.cpp @@ -31,7 +31,7 @@ #endif namespace internal { -inline size_t upScaleAlignment(size_t alignment) { +inline static size_t upScaleAlignment(size_t alignment) { if (1 == alignment) { return sizeof(void *); } @@ -58,8 +58,8 @@ inline size_t upScaleAlignment(size_t alignment) { return alignment; } -void *VKAPI_CALL alloc(void *pUserData, size_t size, size_t alignment, - VkSystemAllocationScope allocationScope) { +static void *VKAPI_CALL alloc(void *pUserData, size_t size, size_t alignment, + VkSystemAllocationScope allocationScope) { // TODO: Use these to instrument how the driver allocates memory and for what // purpose it is used. (void)pUserData; @@ -81,9 +81,9 @@ void *VKAPI_CALL alloc(void *pUserData, size_t size, size_t alignment, return pMemory; } -void *VKAPI_CALL realloc(void *pUserData, void *pOriginal, size_t size, - size_t alignment, - VkSystemAllocationScope allocationScope) { +static void *VKAPI_CALL realloc(void *pUserData, void *pOriginal, size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope) { // TODO: Use these to instrument how the driver allocates memory and for what // purpose it is used. (void)pUserData; @@ -108,7 +108,7 @@ void *VKAPI_CALL realloc(void *pUserData, void *pOriginal, size_t size, return pMemory; } -void VKAPI_CALL free(void *pUserData, void *pMemory) { +static void VKAPI_CALL free(void *pUserData, void *pMemory) { // TODO: Use this to instrument how the driver allocates memroy. (void)pUserData; @@ -121,18 +121,18 @@ void VKAPI_CALL free(void *pUserData, void *pMemory) { #endif } -void VKAPI_CALL internalAlloc(void *pUserData, size_t size, - VkInternalAllocationType allocationType, - VkSystemAllocationScope allocationScope) { +static void VKAPI_CALL internalAlloc(void *pUserData, size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope) { (void)pUserData; (void)size; (void)allocationType; (void)allocationScope; } -void VKAPI_CALL internalFree(void *pUserData, size_t size, - VkInternalAllocationType allocationType, - VkSystemAllocationScope allocationScope) { +static void VKAPI_CALL internalFree(void *pUserData, size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope) { (void)pUserData; (void)size; (void)allocationType; diff --git a/source/vk/source/command_buffer.cpp b/source/vk/source/command_buffer.cpp index 0e306bbb0..39df74c73 100644 --- a/source/vk/source/command_buffer.cpp +++ b/source/vk/source/command_buffer.cpp @@ -302,8 +302,8 @@ void FreeCommandBuffers(vk::device device, vk::command_pool commandPool, commandBuffer->commands.end(), [&commandBuffer](command_info &c) { if (c.type == command_type_bind_descriptorset) { - commandBuffer->allocator.free( - c.bind_descriptorset_command.pDescriptorSets); + commandBuffer->allocator.free(static_cast( + c.bind_descriptorset_command.pDescriptorSets)); } }); } @@ -397,8 +397,8 @@ VkResult ResetCommandBuffer(vk::command_buffer commandBuffer, commandBuffer->commands.end(), [&commandBuffer](command_info &c) { if (c.type == command_type_bind_descriptorset) { - commandBuffer->allocator.free( - c.bind_descriptorset_command.pDescriptorSets); + commandBuffer->allocator.free(static_cast( + c.bind_descriptorset_command.pDescriptorSets)); } }); } @@ -1104,7 +1104,7 @@ void CmdExecuteCommands(vk::command_buffer commandBuffer, } } -inline barrier_group_info *find_barrier_info( +inline static barrier_group_info *find_barrier_info( mux_command_buffer_t mux_command_buffer, vk::command_buffer command_buffer) { auto barrier_iter = diff --git a/source/vk/source/queue.cpp b/source/vk/source/queue.cpp index fb1d463f2..3870a7a32 100644 --- a/source/vk/source/queue.cpp +++ b/source/vk/source/queue.cpp @@ -382,7 +382,7 @@ static VkResult ProcessSubmitInfo(const VkSubmitInfo &submitInfo, !(commandBuffer->usage_flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) { commandBuffer->allocator.free( - command_info.wait_events_command.pEvents); + static_cast(command_info.wait_events_command.pEvents)); } } } diff --git a/source/vk/source/shader_module.cpp b/source/vk/source/shader_module.cpp index 493b256b8..edc24e32d 100644 --- a/source/vk/source/shader_module.cpp +++ b/source/vk/source/shader_module.cpp @@ -55,7 +55,7 @@ VkResult CreateShaderModule(vk::device device, vk::small_vector code( {allocator.getCallbacks(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT}); if (code.assign(pCreateInfo->pCode, - pCreateInfo->pCode + pCreateInfo->codeSize / 4)) { + pCreateInfo->pCode + (pCreateInfo->codeSize / 4))) { return VK_ERROR_OUT_OF_HOST_MEMORY; } diff --git a/source/vk/test/UnitVK/include/UnitVK.h b/source/vk/test/UnitVK/include/UnitVK.h index 8f2ef5d7c..ad3fea1fb 100644 --- a/source/vk/test/UnitVK/include/UnitVK.h +++ b/source/vk/test/UnitVK/include/UnitVK.h @@ -1037,7 +1037,8 @@ class SimpleKernelTest : public uvk::PipelineTest, return nullptr; } char *charPtrToStart = reinterpret_cast(mappedMemoryRegion); - char *charPtrToData = &charPtrToStart[buffer * bufferMemorySz + byteOffset]; + char *charPtrToData = + &charPtrToStart[(buffer * bufferMemorySz) + byteOffset]; return reinterpret_cast(charPtrToData); } diff --git a/source/vk/test/UnitVK/source/FlushMappedMemoryRanges.cpp b/source/vk/test/UnitVK/source/FlushMappedMemoryRanges.cpp index 0bbe916c9..babd35f8f 100644 --- a/source/vk/test/UnitVK/source/FlushMappedMemoryRanges.cpp +++ b/source/vk/test/UnitVK/source/FlushMappedMemoryRanges.cpp @@ -285,7 +285,7 @@ TEST_F(FlushMappedMemoryRanges, Default) { device, 1, &flushMappedMemoryRange)); uint32_t *resultMemory = static_cast(mappedMemory) + - alignedBufferSize / sizeof(uint32_t); + (alignedBufferSize / sizeof(uint32_t)); // validate results for (uint32_t k = 0; k < bufferElements; k++) { diff --git a/source/vk/test/UnitVK/source/MapMemory.cpp b/source/vk/test/UnitVK/source/MapMemory.cpp index 17515bdfe..c46e74a32 100644 --- a/source/vk/test/UnitVK/source/MapMemory.cpp +++ b/source/vk/test/UnitVK/source/MapMemory.cpp @@ -41,7 +41,7 @@ TEST_F(MapMemory, Default) { // un-map and re-map DeviceMemoryTest::unmapMemory(); DeviceMemoryTest::mapMemory(0, dataList.size() * sizeof(uint32_t), - (void **)&mappedMemory); + &mappedMemory); // check the data for (int dataIndex = 0, dataEnd = dataList.size(); dataIndex < dataEnd; diff --git a/source/vk/test/UnitVK/source/UnitVK.cpp b/source/vk/test/UnitVK/source/UnitVK.cpp index 863c1821f..1dddb6191 100644 --- a/source/vk/test/UnitVK/source/UnitVK.cpp +++ b/source/vk/test/UnitVK/source/UnitVK.cpp @@ -38,7 +38,7 @@ #endif namespace uvk { -size_t upScaleAlignment(size_t alignment) { +static size_t upScaleAlignment(size_t alignment) { if (1 == alignment) { return sizeof(void *); } @@ -146,8 +146,9 @@ void VKAPI_CALL freeNotify(void *pUserData, size_t size, (void)allocationScope; } -void *VKAPI_CALL oneUseAlloc(void *pUserData, size_t size, size_t alignment, - VkSystemAllocationScope allocationScope) { +static void *VKAPI_CALL oneUseAlloc(void *pUserData, size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope) { // TODO: Use these to intrument how the driver allocates memory and for what // purpose it is used. (void)allocationScope; diff --git a/source/vk/test/UnitVK/source/ktst_basic.cpp b/source/vk/test/UnitVK/source/ktst_basic.cpp index 54cd8e813..e5a7e0579 100644 --- a/source/vk/test/UnitVK/source/ktst_basic.cpp +++ b/source/vk/test/UnitVK/source/ktst_basic.cpp @@ -23,13 +23,13 @@ TEST_F(ktst_sgemm, BasicCorrectnessTest) { kts::Reference1D refOut = [](size_t x) { switch (x / 4) { case 0: - return 224 + 24 * (x % 4); + return 224 + (24 * (x % 4)); case 1: - return 608 + 88 * (x % 4); + return 608 + (88 * (x % 4)); case 2: - return 992 + 152 * (x % 4); + return 992 + (152 * (x % 4)); default: - return 1376 + 216 * (x % 4); + return 1376 + (216 * (x % 4)); } }; AddPrimitive((glsl::uintTy)4); @@ -130,13 +130,13 @@ TEST_F(ktst_sgemm_custom, BasicCorrectnessTest) { kts::Reference1D refOut = [](size_t x) { switch (x / 4) { case 0: - return 224 + 24 * (x % 4); + return 224 + (24 * (x % 4)); case 1: - return 608 + 88 * (x % 4); + return 608 + (88 * (x % 4)); case 2: - return 992 + 152 * (x % 4); + return 992 + (152 * (x % 4)); default: - return 1376 + 216 * (x % 4); + return 1376 + (216 * (x % 4)); } }; diff --git a/source/vk/test/UnitVK/source/ktst_dma.cpp b/source/vk/test/UnitVK/source/ktst_dma.cpp index 643d39187..c22467731 100644 --- a/source/vk/test/UnitVK/source/ktst_dma.cpp +++ b/source/vk/test/UnitVK/source/ktst_dma.cpp @@ -22,15 +22,15 @@ using namespace kts::uvk; const size_t local_wg_size = 16; // Vector addition: C[i] = A[i] + B[i]; -kts::Reference1D vaddInA = [](size_t x) { - return kts::Ref_Identity(x) * 3 + 27; +static kts::Reference1D vaddInA = [](size_t x) { + return (kts::Ref_Identity(x) * 3) + 27; }; -kts::Reference1D vaddInB = [](size_t x) { - return kts::Ref_Identity(x) * 7 + 41; +static kts::Reference1D vaddInB = [](size_t x) { + return (kts::Ref_Identity(x) * 7) + 41; }; -kts::Reference1D vaddOutC = [](size_t x) { +static kts::Reference1D vaddOutC = [](size_t x) { return vaddInA(x) + vaddInB(x); }; @@ -69,7 +69,7 @@ class DmaAutoConvolutionExecute : public Execution { cl_uint total = totalStart; const cl_uint dstYStride = gsizeX; const cl_uint srcYStride = dstYStride + 16; - cl_uint srcIndex = gidY * srcYStride + gidX + 8; + cl_uint srcIndex = (gidY * srcYStride) + gidX + 8; srcIndex += srcYStride; for (uint32_t yy = 0; yy < 3; yy++) { for (uint32_t xx = 0; xx < 3; xx++) { @@ -77,7 +77,7 @@ class DmaAutoConvolutionExecute : public Execution { continue; } if (((1 << xx) & maskLoop1) && ((1 << xx) & maskLoop2)) { - const cl_uint srcIndexLoop = yy * srcYStride + srcIndex + xx - 1; + const cl_uint srcIndexLoop = (yy * srcYStride) + srcIndex + xx - 1; total = total + inA(srcIndexLoop); } } diff --git a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_03.cpp b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_03.cpp index 57f63402a..c06ae2638 100644 --- a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_03.cpp +++ b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_03.cpp @@ -84,7 +84,7 @@ TEST_F(Execution, Task_03_05_Distance4_Builtin) { const float d1 = (v1.data[1] - v2.data[1]); const float d2 = (v1.data[2] - v2.data[2]); const float d3 = (v1.data[3] - v2.data[3]); - return std::sqrt(d0 * d0 + d1 * d1 + d2 * d2 + d3 * d3); + return std::sqrt((d0 * d0) + (d1 * d1) + (d2 * d2) + (d3 * d3)); }; AddInputBuffer(kts::N, refIn1); @@ -114,7 +114,7 @@ TEST_F(Execution, Task_03_07_Transpose4) { kts::Reference1D refOut = [](size_t x) { const cl_int ix = kts::Ref_Identity(x); const cl_int chunkID = ix % 4; - const cl_int base = (ix - chunkID) * 4 + chunkID; + const cl_int base = ((ix - chunkID) * 4) + chunkID; cl_int4 v; v.data[0] = kts::Ref_A(base + 0); v.data[1] = kts::Ref_A(base + 4); diff --git a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_07.cpp b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_07.cpp index f2e122138..d2c1caefc 100644 --- a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_07.cpp +++ b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_07.cpp @@ -246,7 +246,7 @@ TEST_F(Execution, Task_07_12_Scalar_Masked_Load) { } } -void TestScalarMaskedStore(Execution *e) { +static void TestScalarMaskedStore(Execution *e) { // Test with the first constant that exercises one path. const unsigned C1 = 1; const unsigned N1 = (unsigned)kts::N; @@ -334,7 +334,7 @@ TEST_F(Execution, Task_07_17_If_In_Loop) { if (clspvSupported_) { kts::Reference1D refOut = [](size_t x) { cl_int sum = 0; - for (size_t i = 0; i <= (size_t)x; i++) { + for (size_t i = 0; i <= x; i++) { cl_int val; if (i & 1) { val = kts::Ref_B(x) * 2; @@ -431,7 +431,7 @@ TEST_F(Execution, Task_07_20_Sibling_Loops) { } } -void TestHalfToFloat(Execution *e) { +static void TestHalfToFloat(Execution *e) { const size_t numSamples = 32; const cl_ushort inputs[numSamples] = { // Values required to reproduce #7163. @@ -463,7 +463,7 @@ void TestHalfToFloat(Execution *e) { 0x7f800000, 0xff800000, 0x7f802000, 0xff802000}; kts::Reference1D refIn = [=, &inputs](size_t x) { - return ((size_t)x < numSamples) ? inputs[x] : 0; + return x < numSamples ? inputs[x] : 0; }; kts::Reference1D refOut = [&outputs](size_t x, cl_uint r) { float result; diff --git a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_10.cpp b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_10.cpp index 1d962f2e2..4dc91ffaf 100644 --- a/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_10.cpp +++ b/source/vk/test/UnitVK/source/ktst_vecz_tasks_task_10.cpp @@ -58,9 +58,9 @@ TEST_F(Execution, Task_10_08_InsertElement_Constant_Index) { auto refIn = kts::BuildVec4Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { const cl_int a = kts::Ref_A(4 * x); - const cl_int b = kts::Ref_A(4 * x + 1); + const cl_int b = kts::Ref_A((4 * x) + 1); const cl_int c = 42; - const cl_int d = kts::Ref_A(4 * x + 3); + const cl_int d = kts::Ref_A((4 * x) + 3); return cl_int4{{a, b, c, d}}; }; AddInputBuffer(kts::N, refIn); @@ -77,9 +77,9 @@ TEST_F(Execution, Task_10_09_InsertElement_Runtime_Index) { auto refIn = kts::BuildVec4Reference1D(kts::Ref_A); kts::Reference1D refOut = [](size_t x) { const cl_int a = (x % 4 == 0) ? 42 : kts::Ref_A(4 * x); - const cl_int b = (x % 4 == 1) ? 42 : kts::Ref_A(4 * x + 1); - const cl_int c = (x % 4 == 2) ? 42 : kts::Ref_A(4 * x + 2); - const cl_int d = (x % 4 == 3) ? 42 : kts::Ref_A(4 * x + 3); + const cl_int b = (x % 4 == 1) ? 42 : kts::Ref_A((4 * x) + 1); + const cl_int c = (x % 4 == 2) ? 42 : kts::Ref_A((4 * x) + 2); + const cl_int d = (x % 4 == 3) ? 42 : kts::Ref_A((4 * x) + 3); return cl_int4{{a, b, c, d}}; }; AddInputBuffer(kts::N, refIn);