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

Unified Diff: include/core/SkUtils.h

Issue 1270573002: Port SkUtils opts to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: always inline armv8 Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkOpts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkUtils.h
diff --git a/include/core/SkUtils.h b/include/core/SkUtils.h
index bca76ed54f831d4326997ba54bcd4941c6e158e6..89afdb68cee5b5e97e354e8330d2a2f1bc253980 100644
--- a/include/core/SkUtils.h
+++ b/include/core/SkUtils.h
@@ -10,56 +10,44 @@
#include "SkTypes.h"
-///////////////////////////////////////////////////////////////////////////////
+namespace SkOpts {
+ extern void (*memset16)(uint16_t[], uint16_t, int);
djsollen 2015/07/31 17:25:23 does this mean that SkOpts.h should be in include/
mtklein_C 2015/07/31 17:36:25 Yeah, borderline case. Done.
+ extern void (*memset32)(uint32_t[], uint32_t, int);
+}
-// Determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop.
-#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 || defined(SK_ARM_HAS_NEON)
- // Platforms where we can assume an autovectorizer will give us a good inline memset.
- #define SK_SMALL_MEMSET 1000
-#else
- // Platforms like Chrome on ARMv7 that don't typically compile with NEON globally.
- #define SK_SMALL_MEMSET 10
-#endif
+///////////////////////////////////////////////////////////////////////////////
+// The inlining heuristics below were determined using bench/MemsetBench.cpp
+// on a x86 desktop, a Nexus 7 with and without NEON, and a Nexus 9.
/** Similar to memset(), but it assigns a 16bit value into the buffer.
@param buffer The memory to have value copied into it
@param value The 16bit value to be copied into buffer
@param count The number of times value should be copied into the buffer.
*/
-void sk_memset16_large(uint16_t dst[], uint16_t value, int count);
-inline void sk_memset16(uint16_t dst[], uint16_t value, int count) {
- if (count <= SK_SMALL_MEMSET) {
- for (int i = 0; i < count; i++) {
- dst[i] = value;
- }
- } else {
- sk_memset16_large(dst, value, count);
- }
+static inline void sk_memset16(uint16_t buffer[], uint16_t value, int count) {
+#if defined(SK_CPU_ARM64)
djsollen 2015/07/31 17:25:23 can you add some comments as to why we don't just
mtklein_C 2015/07/31 17:36:25 Done.
+ while (count --> 0) { *buffer++ = value; } return;
+#elif defined(SK_CPU_ARM32)
+ if (count <= 10) { while (count --> 0) { *buffer++ = value; } return; }
+#endif
+ SkOpts::memset16(buffer, value, count);
}
-typedef void (*SkMemset16Proc)(uint16_t dst[], uint16_t value, int count);
-SkMemset16Proc SkMemset16GetPlatformProc();
/** Similar to memset(), but it assigns a 32bit value into the buffer.
@param buffer The memory to have value copied into it
@param value The 32bit value to be copied into buffer
@param count The number of times value should be copied into the buffer.
*/
-void sk_memset32_large(uint32_t dst[], uint32_t value, int count);
-inline void sk_memset32(uint32_t dst[], uint32_t value, int count) {
- if (count <= SK_SMALL_MEMSET) {
- for (int i = 0; i < count; i++) {
- dst[i] = value;
- }
- } else {
- sk_memset32_large(dst, value, count);
- }
+static inline void sk_memset32(uint32_t buffer[], uint32_t value, int count) {
+#if defined(SK_CPU_ARM64)
djsollen 2015/07/31 17:25:23 further why not put this logic in the neon opts fi
mtklein_C 2015/07/31 17:36:25 Done.
+ while (count --> 0) { *buffer++ = value; } return;
+#elif defined(SK_CPU_ARM32)
+ if (count <= 10) { while (count --> 0) { *buffer++ = value; } return; }
+#endif
+ SkOpts::memset32(buffer, value, count);
}
-typedef void (*SkMemset32Proc)(uint32_t dst[], uint32_t value, int count);
-SkMemset32Proc SkMemset32GetPlatformProc();
-
-#undef SK_SMALL_MEMSET
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698