eec9dbcace
This patch adds minimal support for dynamic ARM NEON support, i.e. the ability to probe the CPU at runtime for NEON and provide alternate code paths when it is available. - Add include/core/SkUtilsArm.h, which declares a few helper macros (e.g. SK_NEON_ARM_IS_DYNAMIC), plus the handy function 'sk_cpu_arm_has_neon()' which returns true if the target CPU supports the ARM NEON instruction set. Note that the header is in include/core/ because it will have to be included from NEON-specific code under src/code/ It would probably be more logical to put it under include/opts/ instead, but this would require moving all the NEON-specific stuff under src/code/ into src/opts/, which is not trivial due to the way the code is currently architected. - Add src/core/SkUtilsArm.cpp which implements 'sk_cpu_arm_has_neon' for ARM-based Linux systems, only when SK_NEON_ARM_IS_DYNAMIC is true. (For other cases, 'sk_cpu_arm_has_neon' is an inline function that returns a constant 'true' or 'false' value). There is no user-level accessible CPUID instruction on ARM, so do all CPU feature probing by parsing /proc/cpuinfo. This is Linux-specific. For Debug build types, the CPU probing result is printed to the Android log (or Linux command-line) for easier debugging. - Create a new 'opts_neon' target (static library) which shall contain all the NEON-specific code paths for the library. This is necessary because -mfpu=neon impacts also non-scalar code. Just like with -mssse3 on x86, we can't build the rest of the library with this flag. Note that for now, we only include memset16_neon and memset32_neon in this library. - Modify opts_check_arm.cpp to implement SK_ARM_NEON_IS_DYNAMIC properly. Compared to a 'xoom' build, the only difference is the use of NEON-optimized memset16/32 functions. Later patches will move more NEON-specific code paths to 'opts_neon'. Review URL: https://codereview.appspot.com/6247058 git-svn-id: http://skia.googlecode.com/svn/trunk@4069 2bbb7eff-a529-9590-31e7-b0007b416f81
54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
|
|
/*
|
|
* Copyright 2012 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkUtilsArm_DEFINED
|
|
#define SkUtilsArm_DEFINED
|
|
|
|
#include "SkUtils.h"
|
|
|
|
// Define SK_ARM_NEON_MODE to one of the following values
|
|
// corresponding respectively to:
|
|
// - No ARM Neon support at all (not targetting ARMv7-A, or don't have NEON)
|
|
// - Full ARM Neon support (i.e. assume the CPU always supports it)
|
|
// - Optional ARM Neon support (i.e. probe CPU at runtime)
|
|
//
|
|
#define SK_ARM_NEON_MODE_NONE 0
|
|
#define SK_ARM_NEON_MODE_ALWAYS 1
|
|
#define SK_ARM_NEON_MODE_DYNAMIC 2
|
|
|
|
#if defined(__arm__) && defined(__ARM_HAVE_OPTIONAL_NEON_SUPPORT)
|
|
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_DYNAMIC
|
|
#elif defined(__arm__) && defined(__ARM_HAVE_NEON)
|
|
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_ALWAYS
|
|
#else
|
|
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_NONE
|
|
#endif
|
|
|
|
// Convenience test macros, always defined as 0 or 1
|
|
#define SK_ARM_NEON_IS_NONE (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_NONE)
|
|
#define SK_ARM_NEON_IS_ALWAYS (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_ALWAYS)
|
|
#define SK_ARM_NEON_IS_DYNAMIC (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_DYNAMIC)
|
|
|
|
// The sk_cpu_arm_has_neon() function returns true iff the target device
|
|
// is ARMv7-A and supports Neon instructions. In DYNAMIC mode, this actually
|
|
// probes the CPU at runtime (and caches the result).
|
|
|
|
#if SK_ARM_NEON_IS_NONE
|
|
static bool sk_cpu_arm_has_neon(void) {
|
|
return false;
|
|
}
|
|
#elif SK_ARM_NEON_IS_ALWAYS
|
|
static bool sk_cpu_arm_has_neon(void) {
|
|
return true;
|
|
}
|
|
#else // SK_ARM_NEON_IS_DYNAMIC
|
|
extern bool sk_cpu_arm_has_neon(void);
|
|
#endif
|
|
|
|
#endif // SkUtilsArm_DEFINED
|