Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2018 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #pragma once |
| 25 | |
| 26 | #ifdef __aarch64__ |
| 27 | |
| 28 | #include "transpose_interleave_common.hpp" |
| 29 | |
| 30 | // Generic unblocked transposed 12x32-bit sized specialisation |
| 31 | template <> |
| 32 | template <typename T> |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 33 | inline void TransformImpl<12, 1, true, 4, 4, false>::Transform( |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 34 | T* out, const T* const in, const int stride, |
| 35 | const int x0, const int xmax, const int k0, const int kmax |
| 36 | ) { |
| 37 | // Redirect to a 24 x uint16_t specialisation |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 38 | TransformImpl<24, 1, true, 2, 2, false>::Transform( |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 39 | reinterpret_cast<uint16_t *>(out), |
Kohei Takahashi | cedb78f | 2018-08-23 10:23:52 +0900 | [diff] [blame] | 40 | reinterpret_cast<const uint16_t *>(in), |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 41 | stride*2, x0*2, xmax*2, k0, kmax |
| 42 | ); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | // Generic 24x16-bit sized specialisation |
| 46 | template <> |
| 47 | template <typename T> |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 48 | inline void TransformImpl<24, 1, true, 2, 2, false>::Transform( |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 49 | T* out, const T* const in, const int stride, |
| 50 | const int x0, const int xmax, const int k0, const int kmax |
| 51 | ) { |
| 52 | // Redirect to a uint16_t specialisation |
| 53 | Transform( |
| 54 | reinterpret_cast<uint16_t *>(out), |
Kohei Takahashi | cedb78f | 2018-08-23 10:23:52 +0900 | [diff] [blame] | 55 | reinterpret_cast<const uint16_t *>(in), |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 56 | stride, x0, xmax, k0, kmax |
| 57 | ); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | // Specialised 24 x uint16_t version |
| 61 | template <> |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 62 | inline void TransposeInterleaveCommon<24, uint16_t, uint16_t>::moveblock_1x1(const uint16_t *&in0, uint16_t *out) { |
| 63 | __asm __volatile ( |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 64 | "LDP q0, q1, [%[in0]], #32\n" |
| 65 | "STP q0, q1, [%[out]]\n" |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 66 | ASM_PREFETCH("[%[in0], #192]") |
| 67 | "LDR q2, [%[in0]], #16\n" |
| 68 | "STR q2, [%[out], #32]\n" |
| 69 | : [in0] "+r" (in0), [out] "+r" (out) |
| 70 | : |
| 71 | : "v0", "v1", "v2", "memory" |
| 72 | ); |
| 73 | } |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 74 | |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 75 | template <> |
| 76 | inline void TransposeInterleaveCommon<24, uint16_t, uint16_t>::moveblock_1x2(const uint16_t *&in0, const uint16_t *&in1,uint16_t *out) { |
| 77 | __asm __volatile ( |
| 78 | "LDP q0, q1, [%[in0]], #32\n" |
| 79 | "STP q0, q1, [%[out]]\n" |
| 80 | ASM_PREFETCH("[%[in0], #192]") |
| 81 | "LDR q2, [%[in0]], #16\n" |
| 82 | "LDP q3, q4, [%[in1]], #32\n" |
| 83 | "STP q2, q3, [%[out], #32]\n" |
| 84 | ASM_PREFETCH("[%[in1], #192]") |
| 85 | "LDR q5, [%[in1]], #16\n" |
| 86 | "STP q4, q5, [%[out], #64]\n" |
| 87 | : [in0] "+r" (in0), [in1] "+r" (in1), [out] "+r" (out) |
| 88 | : |
| 89 | : "v0", "v1", "v2", "v3", "v4", "v5", "memory" |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | template <> |
| 94 | inline void TransposeInterleaveCommon<24, uint16_t, uint16_t>::moveblock_1x4(const uint16_t *&in0, const uint16_t *&in1, const uint16_t *&in2, const uint16_t *&in3, uint16_t *out) { |
| 95 | __asm __volatile ( |
| 96 | "LDP q0, q1, [%[in0]], #32\n" |
| 97 | "STP q0, q1, [%[out]]\n" |
| 98 | "LDR q2, [%[in0]], #16\n" |
| 99 | ASM_PREFETCH("[%[in0], #192]") |
| 100 | "LDP q3, q4, [%[in1]], #32\n" |
| 101 | "STP q2, q3, [%[out], #32]\n" |
| 102 | "LDR q5, [%[in1]], #16\n" |
| 103 | ASM_PREFETCH("[%[in1], #192]") |
| 104 | "STP q4, q5, [%[out], #64]\n" |
| 105 | "LDP q6, q7, [%[in2]], #32\n" |
| 106 | "STP q6, q7, [%[out], #96]\n" |
| 107 | "LDR q8, [%[in2]], #16\n" |
| 108 | ASM_PREFETCH("[%[in2], #192]") |
| 109 | "LDP q9, q10, [%[in3]], #32\n" |
| 110 | "STP q8, q9, [%[out], #128]\n" |
| 111 | "LDR q11, [%[in3]], #16\n" |
| 112 | "STP q10, q11, [%[out], #160]\n" |
| 113 | ASM_PREFETCH("[%[in3], #192]") |
| 114 | |
| 115 | : [in0] "+r" (in0), [in1] "+r" (in1), [in2] "+r" (in2), [in3] "+r" (in3), [out] "+r" (out) |
| 116 | : |
| 117 | : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "memory" |
| 118 | ); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | template <> |
| 122 | template <> |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 123 | inline void TransformImpl<24, 1, true, 2, 2, false>::Transform( |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 124 | uint16_t* out, const uint16_t* const in, const int stride, |
| 125 | const int x0, const int xmax, const int k0, const int kmax |
| 126 | ) { |
| 127 | TransposeInterleaveCommon<24, uint16_t, uint16_t>::Transform(out, in, stride, x0, xmax, k0, kmax); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 130 | #endif // __arch64__ |