From 47ea34cf7ca5fa0723b718800a1aaae84daf4d10 Mon Sep 17 00:00:00 2001 From: "Maronas, Marcos" Date: Thu, 7 Nov 2024 18:13:59 +0100 Subject: [PATCH] Fix clang-format issues. --- .../LLVMIntrinsicLowering/intrinsic_cmp.cpp | 101 +++++++++--------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/sycl/test-e2e/LLVMIntrinsicLowering/intrinsic_cmp.cpp b/sycl/test-e2e/LLVMIntrinsicLowering/intrinsic_cmp.cpp index 551fed476b4af..723b17a102891 100644 --- a/sycl/test-e2e/LLVMIntrinsicLowering/intrinsic_cmp.cpp +++ b/sycl/test-e2e/LLVMIntrinsicLowering/intrinsic_cmp.cpp @@ -18,26 +18,24 @@ typedef uint64_t v4u64_t __attribute__((ext_vector_type(4))); // Check if a given type is a vector type or not. Used in submitAndCheck to // branch the check: we need element-wise comparison for vector types. Default // case: T is not a vector type. -template -struct is_vector : std::false_type {}; +template struct is_vector : std::false_type {}; // Specialization for vector types. If T has // __attribute__((ext_vector_type(N))), then it's a vector type. template struct is_vector : std::true_type {}; -template -inline constexpr bool is_vector_v = is_vector::value; +template inline constexpr bool is_vector_v = is_vector::value; // Get the length of a vector type. Used in submitAndCheck to iterate over the // elements of the vector type. Default case: length is 1. template struct vector_length { - static constexpr std::size_t value = 1; + static constexpr std::size_t value = 1; }; // Specialization for vector types. If T has // __attribute__((ext_vector_type(N))), then the length is N. template struct vector_length { - static constexpr std::size_t value = N; + static constexpr std::size_t value = N; }; template inline constexpr std::size_t vector_length_v = vector_length::value; @@ -50,7 +48,7 @@ struct element_type; // Specialization for vector types. If T has __attribute__((ext_vector_type(N))), return T. template struct element_type { - using type = T; + using type = T; }; // Helper alias template. template @@ -64,41 +62,41 @@ struct TypeList {}; // Function to trigger llvm.scmp/ucmp. template void compare(RetTy &res, ArgTy x, ArgTy y) { - auto lessOrEq = (x <= y); - auto lessThan = (x < y); - res = lessOrEq ? (lessThan ? RetTy(-1) : RetTy(0)) : RetTy(1); + auto lessOrEq = (x <= y); + auto lessThan = (x < y); + res = lessOrEq ? (lessThan ? RetTy(-1) : RetTy(0)) : RetTy(1); } // Function to submit kernel and check device result with host result. template void submitAndCheck(sycl::queue &q, ArgTy x, ArgTy y) { - RetTy res; - { - sycl::buffer res_b{&res, 1}; - q.submit([&](sycl::handler &cgh) { - sycl::accessor acc{res_b, cgh, sycl::write_only}; - cgh.single_task<>([=] { - RetTy tmp; - compare(tmp, x, y); - acc[0] = tmp; - }); - }); - } - RetTy expectedRes; - compare(expectedRes, x, y); - if constexpr (is_vector_v) { - for (int i = 0; i < vector_length_v; ++i) { - assert(res[i] == expectedRes[i]); - } - } else { - assert(res == expectedRes); + RetTy res; + { + sycl::buffer res_b{&res, 1}; + q.submit([&](sycl::handler &cgh) { + sycl::accessor acc{res_b, cgh, sycl::write_only}; + cgh.single_task<>([=] { + RetTy tmp; + compare(tmp, x, y); + acc[0] = tmp; + }); + }); + } + RetTy expectedRes; + compare(expectedRes, x, y); + if constexpr (is_vector_v) { + for (int i = 0; i < vector_length_v; ++i) { + assert(res[i] == expectedRes[i]); } + } else { + assert(res == expectedRes); + } } // Helper to call submitAndCheck for each combination. template void submitAndCheckCombination(sycl::queue &q, int x, int y) { - submitAndCheck(q, x, y); + submitAndCheck(q, x, y); } // Function to generate all the combinations possible with the two type lists. @@ -110,8 +108,8 @@ void submitAndCheckCombination(sycl::queue &q, int x, int y) { // Recursive case to generate combinations. template void submitCombinations(sycl::queue &q, int x, int y, TypeList, TypeList) { - (submitAndCheckCombination(q, x, y), ...); - submitCombinations(q, x, y, TypeList{}, TypeList{}); + (submitAndCheckCombination(q, x, y), ...); + submitCombinations(q, x, y, TypeList{}, TypeList{}); } // Base case to stop recursion. template @@ -125,26 +123,29 @@ void submitCombinations(sycl::queue &, int, int, TypeList<>, TypeList void submitVecCombinations(sycl::queue &q, int x, int y, TypeList) { - // Use signed types for return type, as it may return -1. - using ElemType = std::make_signed_t>; - using RetType = ElemType __attribute__((ext_vector_type(vector_length_v))); - submitAndCheckCombination(q, x, y); - submitVecCombinations(q, x, y, TypeList{}); + // Use signed types for return type, as it may return -1. + using ElemType = std::make_signed_t>; + using RetType = + ElemType __attribute__((ext_vector_type(vector_length_v))); + submitAndCheckCombination(q, x, y); + submitVecCombinations(q, x, y, TypeList{}); } // Base case to stop recursion. void submitVecCombinations(sycl::queue &, int, int, TypeList<>) {} int main(int argc, char **argv) { - sycl::queue q; - // RetTypes includes only signed types because it may return -1. - using RetTypes = TypeList; - using ArgTypes = TypeList; - submitCombinations(q, 50, 49, RetTypes{}, ArgTypes{}); - submitCombinations(q, 50, 50, RetTypes{}, ArgTypes{}); - submitCombinations(q, 50, 51, RetTypes{}, ArgTypes{}); - using VecTypes = TypeList; - submitVecCombinations(q, 50, 49, VecTypes{}); - submitVecCombinations(q, 50, 50, VecTypes{}); - submitVecCombinations(q, 50, 51, VecTypes{}); - return 0; + sycl::queue q; + // RetTypes includes only signed types because it may return -1. + using RetTypes = TypeList; + using ArgTypes = TypeList; + submitCombinations(q, 50, 49, RetTypes{}, ArgTypes{}); + submitCombinations(q, 50, 50, RetTypes{}, ArgTypes{}); + submitCombinations(q, 50, 51, RetTypes{}, ArgTypes{}); + using VecTypes = TypeList; + submitVecCombinations(q, 50, 49, VecTypes{}); + submitVecCombinations(q, 50, 50, VecTypes{}); + submitVecCombinations(q, 50, 51, VecTypes{}); + return 0; }