sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\bench\t_memfnc.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32std_private.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <e32base_private.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
const TInt Len64K = 64*1024;
|
sl@0
|
24 |
|
sl@0
|
25 |
volatile extern TInt count;
|
sl@0
|
26 |
volatile extern TInt iters;
|
sl@0
|
27 |
extern TInt8* trg;
|
sl@0
|
28 |
extern TInt8* src;
|
sl@0
|
29 |
extern TInt8 trgoffset;
|
sl@0
|
30 |
extern TInt8 srcoffset;
|
sl@0
|
31 |
extern TInt len;
|
sl@0
|
32 |
|
sl@0
|
33 |
GLREF_C TInt PurgeCache()
|
sl@0
|
34 |
{
|
sl@0
|
35 |
TInt8* purgetrg;
|
sl@0
|
36 |
TInt8* purgesrc;
|
sl@0
|
37 |
|
sl@0
|
38 |
purgetrg=(TInt8*)User::Alloc(Len64K);
|
sl@0
|
39 |
purgesrc=(TInt8*)User::Alloc(Len64K);
|
sl@0
|
40 |
|
sl@0
|
41 |
Mem::Copy(purgetrg,purgesrc,Len64K);
|
sl@0
|
42 |
|
sl@0
|
43 |
User::Free(purgetrg);
|
sl@0
|
44 |
User::Free(purgesrc);
|
sl@0
|
45 |
return 0;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
TInt MemBaseline(TAny*)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
FOREVER
|
sl@0
|
51 |
{
|
sl@0
|
52 |
for (iters=0; iters<8192; )
|
sl@0
|
53 |
{
|
sl@0
|
54 |
// eight off, unrolled for accuracy
|
sl@0
|
55 |
iters++;
|
sl@0
|
56 |
iters++;
|
sl@0
|
57 |
iters++;
|
sl@0
|
58 |
iters++;
|
sl@0
|
59 |
|
sl@0
|
60 |
iters++;
|
sl@0
|
61 |
iters++;
|
sl@0
|
62 |
iters++;
|
sl@0
|
63 |
iters++;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
count++;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
TInt MemCopy(TAny*)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
FOREVER
|
sl@0
|
73 |
{
|
sl@0
|
74 |
Mem::Copy(trgoffset+trg,srcoffset+src,len);
|
sl@0
|
75 |
count++;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
TInt MemFill(TAny*)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
FOREVER
|
sl@0
|
82 |
{
|
sl@0
|
83 |
Mem::Fill(trgoffset+trg,len,42);
|
sl@0
|
84 |
count++;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
TInt MemSwap(TAny*)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
FOREVER
|
sl@0
|
91 |
{
|
sl@0
|
92 |
Mem::Swap(trgoffset+trg,srcoffset+src,len);
|
sl@0
|
93 |
count++;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
/// For lengths smaller than the allocated size of 64K. Pointers are stepped
|
sl@0
|
98 |
/// though RAM so that we never hit the cache. Stepping is done backwards to
|
sl@0
|
99 |
/// foil any automatic preparation for loading of the next cache line.
|
sl@0
|
100 |
TInt MemCopyUncached(TAny*)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
TUint step = (len + 31) & (~31); // length rounded up to cache line size
|
sl@0
|
103 |
|
sl@0
|
104 |
TInt8* slimit = src + 2*Len64K - step + srcoffset;
|
sl@0
|
105 |
TInt8* tlimit = trg + 2*Len64K - step + trgoffset;
|
sl@0
|
106 |
|
sl@0
|
107 |
TInt8* s = slimit;
|
sl@0
|
108 |
TInt8* t = tlimit;
|
sl@0
|
109 |
|
sl@0
|
110 |
FOREVER
|
sl@0
|
111 |
{
|
sl@0
|
112 |
Mem::Copy(t,s,len);
|
sl@0
|
113 |
s -= step;
|
sl@0
|
114 |
t -= step;
|
sl@0
|
115 |
if (s < src)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
s = slimit;
|
sl@0
|
118 |
t = tlimit;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
count++;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
// See comments for MemCopyUncached above
|
sl@0
|
125 |
TInt MemFillUncached(TAny*)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TUint step = (len + 31) & (~31); // length rounded up to cache line size
|
sl@0
|
128 |
|
sl@0
|
129 |
TInt8* tlimit = trg + 2*Len64K - step + trgoffset;
|
sl@0
|
130 |
TInt8* t = tlimit;
|
sl@0
|
131 |
|
sl@0
|
132 |
FOREVER
|
sl@0
|
133 |
{
|
sl@0
|
134 |
Mem::Fill(t,len,42);
|
sl@0
|
135 |
t -= step;
|
sl@0
|
136 |
if (t < trg)
|
sl@0
|
137 |
t = tlimit;
|
sl@0
|
138 |
count++;
|
sl@0
|
139 |
}
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
TInt WordMove(TAny*)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
FOREVER
|
sl@0
|
145 |
{
|
sl@0
|
146 |
wordmove(trgoffset+trg,srcoffset+src,len);
|
sl@0
|
147 |
count++;
|
sl@0
|
148 |
}
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
// See comments for MemCopyUncached above
|
sl@0
|
152 |
TInt WordMoveUncached(TAny*)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
TUint step = (len + 31) & (~31); // length rounded up to cache line size
|
sl@0
|
155 |
|
sl@0
|
156 |
TInt8* slimit = src + 2*Len64K - step + srcoffset;
|
sl@0
|
157 |
TInt8* tlimit = trg + 2*Len64K - step + trgoffset;
|
sl@0
|
158 |
|
sl@0
|
159 |
TInt8* s = slimit;
|
sl@0
|
160 |
TInt8* t = tlimit;
|
sl@0
|
161 |
|
sl@0
|
162 |
FOREVER
|
sl@0
|
163 |
{
|
sl@0
|
164 |
wordmove(t,s,len);
|
sl@0
|
165 |
s -= step;
|
sl@0
|
166 |
t -= step;
|
sl@0
|
167 |
if (s < src)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
s = slimit;
|
sl@0
|
170 |
t = tlimit;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
count++;
|
sl@0
|
173 |
}
|
sl@0
|
174 |
}
|