summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Nehls <nehls@mi.fu-berlin.de>2011-05-21 17:07:28 +0200
committerRobin Nehls <nehls@mi.fu-berlin.de>2011-05-21 17:07:28 +0200
commitd8d4f48375bdef25d0bf445796eca300e47c9a07 (patch)
tree51f1dcfae41377b5d7debd62688049ea4aa83f26
parent8e310fdf6917bf16d7dc4d07a29a803ae4e1d4ce (diff)
downloadmanycore-d8d4f48375bdef25d0bf445796eca300e47c9a07.tar.gz
manycore-d8d4f48375bdef25d0bf445796eca300e47c9a07.tar.bz2
manycore-d8d4f48375bdef25d0bf445796eca300e47c9a07.zip
added cmd line options (recompiling suxx)
-rw-r--r--cacheRows2.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/cacheRows2.c b/cacheRows2.c
index e6295f6..d10c3bb 100644
--- a/cacheRows2.c
+++ b/cacheRows2.c
@@ -2,37 +2,49 @@
#include <stdlib.h>
#include "inlineasm.h"
-#define FIELD_SIZE 5000
-#define MIN_TIME 120
-#define MAX_TIME 1000
-
-int main(int argc, char* argv[])
-{
- char *field1 = malloc(FIELD_SIZE);
- char *field2 = malloc(FIELD_SIZE);
+int main(int argc, char* argv[])
+{
+ if (argc != 5) {
+ printf("Usage: %s <fieldsize> <minticks> <maxticks> <outputfile>\n",argv[0]);
+ return 1;
+ }
+
+ unsigned long i,j,time,fieldsize,minticks,maxticks;
+
+ sscanf(argv[1],"%lu",&fieldsize);
+ sscanf(argv[2],"%lu",&minticks);
+ sscanf(argv[3],"%lu",&maxticks);
+
+ char *field1 = malloc(fieldsize);
+ char *field2 = malloc(fieldsize);
char *current = field1;
- unsigned long i,j;
- unsigned long time=0;
- FILE *f=stdout;
+ FILE *f;
+
+ if (argv[4][0] == '-') {
+ f=stdout;
+ }
+ else {
+ f=fopen(argv[4],"w");
+ }
- // fill arrays with crap
- for (i=0;i < FIELD_SIZE; ++i) {
- field1[i]=(i+2342) % 255;
+ // fill arrays with crap
+ for (i=0;i < fieldsize; ++i) {
+ field1[i]=(i+2342) % 255;
field2[i]=(i+4223) % 255;
- }
-
+ }
+
// print table reader
if (argc == 1) {
f=fopen("output.dat","w");
fprintf(f,"Offset Ticks\n");
}
- for(i=0; i<FIELD_SIZE; ++i) {
- time=memmeasure(current,i);
- if (time < MAX_TIME && time > MIN_TIME )
+ for(i=0; i<fieldsize; ++i) {
+ time=memmeasure(current,i);
+ if (time < maxticks && time > minticks )
fprintf(f,"%lu %lu\n",i,time);
- // scrambeled eggs
+ // scrambeled eggs
if (current == field1) {
current = field2;
}
@@ -40,9 +52,9 @@ int main(int argc, char* argv[])
current = field1;
}
- }
+ }
fclose(f);
-
- return 0;
+
+ return 0;
}