/* * Copyright (c) 2018, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
/** * Various reusable shorthands for x86 SIMD intrinsics. * * Intrinsics prefixed with xx_ operate on or return 128bit XMM registers. * Intrinsics prefixed with yy_ operate on or return 256bit YMM registers.
*/
// Loads and stores to do away with the tedium of casting the address // to the right type. staticinline __m256i yy_load_256(constvoid *a) { return _mm256_load_si256((const __m256i *)a);
}
// Fill an AVX register using an interleaved pair of values, ie. set the // 16 channels to {a, b} repeated 8 times, using the same channel ordering // as when a register is stored to / loaded from memory. // // This is useful for rearranging filter kernels for use with the _mm_madd_epi16 // instruction staticinline __m256i yy_set2_epi16(int16_t a, int16_t b) { return _mm256_setr_epi16(a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b);
}
// Some compilers don't have _mm256_set_m128i defined in immintrin.h. We // therefore define an equivalent function using a different intrinsic. // ([ hi ], [ lo ]) -> [ hi ][ lo ] staticinline __m256i yy_set_m128i(__m128i hi, __m128i lo) { return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1);
}
// This behaves similarly to _mm256_set_epi64x(), but avoids undefined // sanitizer warnings when loading values from unaligned buffers using // `*(int64_t *)val`. staticinline __m256i yy_loadu_4x64(constvoid *e3, constvoid *e2, constvoid *e1, constvoid *e0) {
__m128d v0 = _mm_castsi128_pd(_mm_loadl_epi64((const __m128i *)e0));
__m128d v01 = _mm_loadh_pd(v0, (constdouble *)e1);
__m128d v2 = _mm_castsi128_pd(_mm_loadl_epi64((const __m128i *)e2));
__m128d v23 = _mm_loadh_pd(v2, (constdouble *)e3); // Note this can be replaced with // `_mm256_castpd_si256(_mm256_set_m128d(v23, v01))` if immintrin.h contains // _mm256_set_m128d() with all supported compilers. This version is used to // match the behavior with yy_set_m128i(). return yy_set_m128i(_mm_castpd_si128(v23), _mm_castpd_si128(v01));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.