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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « bench/MemsetBench.cpp ('k') | src/core/SkUtils.cpp » ('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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkUtils_DEFINED 8 #ifndef SkUtils_DEFINED
9 #define SkUtils_DEFINED 9 #define SkUtils_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 /////////////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////////////
14 14
15 /** Similar to memset(), but it assigns a 16bit value into the buffer. 15 /** Similar to memset(), but it assigns a 16bit value into the buffer.
16 @param buffer The memory to have value copied into it 16 @param buffer The memory to have value copied into it
17 @param value The 16bit value to be copied into buffer 17 @param value The 16bit value to be copied into buffer
18 @param count The number of times value should be copied into the buffer. 18 @param count The number of times value should be copied into the buffer.
19 */ 19 */
20 void sk_memset16(uint16_t dst[], uint16_t value, int count); 20 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.
21 inline void sk_memset16(uint16_t dst[], uint16_t value, int count) {
22 // 10 determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop.
23 // (N7 was the limiting factor; desktops and N9 consider 10,000 small but 10 0,000 large).
24 if (count <= 10) {
25 for (int i = 0; i < count; i++) {
26 dst[i] = value;
27 }
28 } else {
29 sk_memset16_large(dst, value, count);
30 }
31 }
21 typedef void (*SkMemset16Proc)(uint16_t dst[], uint16_t value, int count); 32 typedef void (*SkMemset16Proc)(uint16_t dst[], uint16_t value, int count);
22 SkMemset16Proc SkMemset16GetPlatformProc(); 33 SkMemset16Proc SkMemset16GetPlatformProc();
23 34
24 /** Similar to memset(), but it assigns a 32bit value into the buffer. 35 /** Similar to memset(), but it assigns a 32bit value into the buffer.
25 @param buffer The memory to have value copied into it 36 @param buffer The memory to have value copied into it
26 @param value The 32bit value to be copied into buffer 37 @param value The 32bit value to be copied into buffer
27 @param count The number of times value should be copied into the buffer. 38 @param count The number of times value should be copied into the buffer.
28 */ 39 */
29 void sk_memset32(uint32_t dst[], uint32_t value, int count); 40 void sk_memset32_large(uint32_t dst[], uint32_t value, int count);
41 inline void sk_memset32(uint32_t dst[], uint32_t value, int count) {
42 // 10 determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop.
43 // (N7 was the limiting factor; desktops and N9 consider 10,000 small but 10 0,000 large).
44 if (count <= 10) {
45 for (int i = 0; i < count; i++) {
46 dst[i] = value;
47 }
48 } else {
49 sk_memset32_large(dst, value, count);
50 }
51 }
52
30 typedef void (*SkMemset32Proc)(uint32_t dst[], uint32_t value, int count); 53 typedef void (*SkMemset32Proc)(uint32_t dst[], uint32_t value, int count);
31 SkMemset32Proc SkMemset32GetPlatformProc(); 54 SkMemset32Proc SkMemset32GetPlatformProc();
32 55
33 /** Similar to memcpy(), but it copies count 32bit values from src to dst. 56 /** Similar to memcpy(), but it copies count 32bit values from src to dst.
34 @param dst The memory to have value copied into it 57 @param dst The memory to have value copied into it
35 @param src The memory to have value copied from it 58 @param src The memory to have value copied from it
36 @param count The number of values should be copied. 59 @param count The number of values should be copied.
37 */ 60 */
38 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count); 61 void sk_memcpy32(uint32_t dst[], const uint32_t src[], int count);
39 typedef void (*SkMemcpy32Proc)(uint32_t dst[], const uint32_t src[], int count); 62 typedef void (*SkMemcpy32Proc)(uint32_t dst[], const uint32_t src[], int count);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 132 }
110 ~SkAutoTrace() { 133 ~SkAutoTrace() {
111 SkDebugf("--- trace: %s Leave\n", fLabel); 134 SkDebugf("--- trace: %s Leave\n", fLabel);
112 } 135 }
113 private: 136 private:
114 const char* fLabel; 137 const char* fLabel;
115 }; 138 };
116 #define SkAutoTrace(...) SK_REQUIRE_LOCAL_VAR(SkAutoTrace) 139 #define SkAutoTrace(...) SK_REQUIRE_LOCAL_VAR(SkAutoTrace)
117 140
118 #endif 141 #endif
OLDNEW
« 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