Sanchayan Maity
2fcc51c2c1
While at it also add the libpthread static library amd m5op_x86 for matrix multiplication test code as well. Note that the splash2 benchmark code does not comply with gem5 coding guidelines. Academic guys never seem to follow 80 columns and no whitespace guideline :(.
71 lines
2 KiB
C
71 lines
2 KiB
C
/*************************************************************************/
|
|
/* */
|
|
/* Copyright (c) 1994 Stanford University */
|
|
/* */
|
|
/* All rights reserved. */
|
|
/* */
|
|
/* Permission is given to use, copy, and modify this software for any */
|
|
/* non-commercial purpose as long as this copyright notice is not */
|
|
/* removed. All other uses, including redistribution in whole or in */
|
|
/* part, are forbidden without prior written permission. */
|
|
/* */
|
|
/* This software is provided with absolutely no warranty and no */
|
|
/* support. */
|
|
/* */
|
|
/*************************************************************************/
|
|
|
|
EXTERN_ENV
|
|
#define global extern
|
|
|
|
#include "stdinc.h"
|
|
|
|
#define HZ 60.0
|
|
#define MULT 1103515245
|
|
#define ADD 12345
|
|
#define MASK (0x7FFFFFFF)
|
|
#define TWOTO31 2147483648.0
|
|
|
|
local long A = 1;
|
|
local long B = 0;
|
|
local long randx = 1;
|
|
local long lastrand; /* the last random number */
|
|
|
|
/*
|
|
* XRAND: generate floating-point random number.
|
|
*/
|
|
|
|
double xrand(double xl, double xh)
|
|
{
|
|
return (xl + (xh - xl) * prand());
|
|
}
|
|
|
|
void pranset(long seed)
|
|
{
|
|
A = 1;
|
|
B = 0;
|
|
randx = (A*seed+B) & MASK;
|
|
A = (MULT * A) & MASK;
|
|
B = (MULT*B + ADD) & MASK;
|
|
}
|
|
|
|
double prand()
|
|
/*
|
|
Return a random double in [0, 1.0)
|
|
*/
|
|
{
|
|
lastrand = randx;
|
|
randx = (A*randx+B) & MASK;
|
|
return((double)lastrand/TWOTO31);
|
|
}
|
|
|
|
/*
|
|
* CPUTIME: compute CPU time in min.
|
|
*/
|
|
double cputime()
|
|
{
|
|
struct tms buffer;
|
|
|
|
if (times(&buffer) == (clock_t)-1)
|
|
error("times() call failed\n");
|
|
return (buffer.tms_utime / (60.0 * HZ));
|
|
}
|