Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: source/cpu_id.cc

Issue 1505673003: Optimize yuv alpha blend AVX2 code to do 32 pixels at time. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: merge cpuid changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | source/planar_functions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "libyuv/cpu_id.h" 11 #include "libyuv/cpu_id.h"
12 12
13 #if (defined(_MSC_VER) && !defined(__clang__)) && !defined(__clang__) 13 #if defined(_MSC_VER) && !defined(__clang__)
14 #include <intrin.h> // For __cpuidex() 14 #include <intrin.h> // For __cpuidex()
15 #endif 15 #endif
16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \ 16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \
17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \ 17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \
18 defined(_MSC_VER) && !defined(__clang__) && (_MSC_FULL_VER >= 160040219) 18 defined(_MSC_VER) && !defined(__clang__) && (_MSC_FULL_VER >= 160040219)
19 #include <immintrin.h> // For _xgetbv() 19 #include <immintrin.h> // For _xgetbv()
20 #endif 20 #endif
21 21
22 #if !defined(__native_client__) 22 #if !defined(__native_client__)
23 #include <stdlib.h> // For getenv() 23 #include <stdlib.h> // For getenv()
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 cpu_info = ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) | 200 cpu_info = ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
201 ((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) | 201 ((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) |
202 ((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) | 202 ((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) |
203 ((cpu_info1[2] & 0x00100000) ? kCpuHasSSE42 : 0) | 203 ((cpu_info1[2] & 0x00100000) ? kCpuHasSSE42 : 0) |
204 ((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0) | 204 ((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0) |
205 ((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) | 205 ((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) |
206 kCpuHasX86; 206 kCpuHasX86;
207 207
208 #ifdef HAS_XGETBV 208 #ifdef HAS_XGETBV
209 // AVX requires CPU has AVX, XSAVE and OSXSave for xgetbv 209 // AVX requires CPU has AVX, XSAVE and OSXSave for xgetbv
210 if ((cpu_info1[2] & 0x1c000000) == 0x1c000000 && // AVX and OSXSave 210 if (((cpu_info1[2] & 0x1c000000) == 0x1c000000) && // AVX and OSXSave
211 (GetXCR0() & 6) == 6) { // Test OD saves YMM registers 211 ((GetXCR0() & 6) == 6)) { // Test OS saves YMM registers
212 cpu_info |= ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) | kCpuHasAVX; 212 cpu_info |= ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) | kCpuHasAVX;
213 213
214 // Detect AVX512bw 214 // Detect AVX512bw
215 if ((GetXCR0() & 0xe0) == 0xe0) { 215 if ((GetXCR0() & 0xe0) == 0xe0) {
216 cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX3 : 0; 216 cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX3 : 0;
217 } 217 }
218 } 218 }
219 #endif 219 #endif
220 220
221 // Environment variable overrides for testing. 221 // Environment variable overrides for testing.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Note that use of this function is not thread safe. 295 // Note that use of this function is not thread safe.
296 LIBYUV_API 296 LIBYUV_API
297 void MaskCpuFlags(int enable_flags) { 297 void MaskCpuFlags(int enable_flags) {
298 cpu_info_ = InitCpuFlags() & enable_flags; 298 cpu_info_ = InitCpuFlags() & enable_flags;
299 } 299 }
300 300
301 #ifdef __cplusplus 301 #ifdef __cplusplus
302 } // extern "C" 302 } // extern "C"
303 } // namespace libyuv 303 } // namespace libyuv
304 #endif 304 #endif
OLDNEW
« no previous file with comments | « no previous file | source/planar_functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698