~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to benchmarks/multi/harness.c

  • Committer: Will Newton
  • Date: 2013-06-17 07:58:27 UTC
  • Revision ID: will.newton@linaro.org-20130617075827-zjh43txfqk6j5q6r
Support buffers larger than 1MB and fill the whole buffer with random
data rather than just the first 16kB. This avoids the situation of
using calloc'd zero pages as the src buffer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
  return (char *)pp;
205
205
}
206
206
 
 
207
#define MIN_BUFFER_SIZE 1024*1024
 
208
 
207
209
/** Setup and run a test */
208
210
int main(int argc, char **argv)
209
211
{
210
 
  /* Buffers to read and write from */
211
 
  char *src = calloc(1024, 1024);
212
 
  char *dest = calloc(1024, 1024);
213
 
 
214
 
  assert(src != NULL && dest != NULL);
 
212
  /* Size of src and dest buffers */
 
213
  size_t buffer_size = MIN_BUFFER_SIZE;
215
214
 
216
215
  /* Number of bytes per call */
217
216
  int count = 31;
268
267
      usage(argv[0]);
269
268
    }
270
269
 
 
270
  if (alignment == 256)
 
271
    alignment = 0;
 
272
 
 
273
  if (count + alignment > MIN_BUFFER_SIZE)
 
274
    {
 
275
      buffer_size = count + alignment;
 
276
    }
 
277
 
 
278
  /* Buffers to read and write from */
 
279
  char *src = malloc(buffer_size);
 
280
  char *dest = malloc(buffer_size);
 
281
 
 
282
  assert(src != NULL && dest != NULL);
 
283
 
271
284
  src = realign(src, alignment);
272
285
  dest = realign(dest, alignment);
273
286
 
274
 
  /* Fill the first 16 k with non-zero, reproducable random data */
 
287
  /* Fill the buffer with non-zero, reproducable random data */
275
288
  srandom(1539);
276
289
 
277
 
  for (int i = 0; i < 16*1024; i++)
 
290
  for (int i = 0; i < buffer_size; i++)
278
291
    {
279
292
      src[i] = (char)random() | 1;
280
293
      dest[i] = src[i];