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

Unified Diff: include/core/SkUtils.h

Issue 1073863002: Rewrite memset benches, then use results to add a small-N optimization. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 8 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 | « bench/MemsetBench.cpp ('k') | src/core/SkUtils.cpp » ('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 d522ae0dea139555f6e8790ac06d8287e5771fd7..c0e91eef9ff9f0a40b3d3c0d72632f8ecf4c2c3a 100644
--- a/include/core/SkUtils.h
+++ b/include/core/SkUtils.h
@@ -17,7 +17,18 @@
@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(uint16_t dst[], uint16_t value, int count);
+void sk_memset16_large(uint16_t dst[], uint16_t value, int count);
reed1 2015/04/09 18:55:48 Seems like its not much harder to provide both N v
mtklein 2015/04/09 19:11:10 Good point! Done.
+inline void sk_memset16(uint16_t dst[], uint16_t value, int count) {
+ // 10 determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop.
+ // (N7 was the limiting factor; desktops and N9 consider 10,000 small but 100,000 large).
+ if (count <= 10) {
+ for (int i = 0; i < count; i++) {
+ dst[i] = value;
+ }
+ } else {
+ sk_memset16_large(dst, value, count);
+ }
+}
typedef void (*SkMemset16Proc)(uint16_t dst[], uint16_t value, int count);
SkMemset16Proc SkMemset16GetPlatformProc();
@@ -26,7 +37,19 @@ SkMemset16Proc SkMemset16GetPlatformProc();
@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(uint32_t dst[], uint32_t value, int count);
+void sk_memset32_large(uint32_t dst[], uint32_t value, int count);
+inline void sk_memset32(uint32_t dst[], uint32_t value, int count) {
+ // 10 determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop.
+ // (N7 was the limiting factor; desktops and N9 consider 10,000 small but 100,000 large).
+ if (count <= 10) {
+ for (int i = 0; i < count; i++) {
+ dst[i] = value;
+ }
+ } else {
+ sk_memset32_large(dst, value, count);
+ }
+}
+
typedef void (*SkMemset32Proc)(uint32_t dst[], uint32_t value, int count);
SkMemset32Proc SkMemset32GetPlatformProc();
« no previous file with comments | « bench/MemsetBench.cpp ('k') | src/core/SkUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698