[llvm-commits] CVS: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.c IOtest.h IOtest.readme IOtestA.c IOtestB.c IOtestC.c Makefile
Chris Lattner
lattner at cs.uiuc.edu
Mon May 12 13:48:01 PDT 2003
Changes in directory llvm/test/Programs/MultiSource/McCat-12-IOtest:
IOtest.c added (r1.1)
IOtest.h added (r1.1)
IOtest.readme added (r1.1)
IOtestA.c added (r1.1)
IOtestB.c added (r1.1)
IOtestC.c added (r1.1)
Makefile added (r1.1)
---
Log message:
Initial checkin
---
Diffs of the changes:
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.c:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.c Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,93 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ #include "IOtest.h"
+ #include <stdlib.h>
+
+ #define IOTEST_SIZE (53681*50) /* prime number */ /* 53681 19170419 67108933 */
+
+ char *testarray;
+ unsigned long array_count;
+
+ unsigned long getac(void)
+ /* {{{ */
+
+ {
+ return array_count;
+ }
+
+ /* }}} */
+
+ void setac(unsigned long i)
+ {
+ array_count=(i % IOTEST_SIZE);
+ }
+
+ void initarray(void)
+ {
+ unsigned long i;
+ i=0;
+ while(i<IOTEST_SIZE)
+ {
+ testarray[i]= i % 255;
+ i++;
+ }
+ }
+
+ char array(unsigned long i)
+ {
+ return testarray[i];
+ }
+
+ char min(char a, char b)
+ {
+ return (a>b)? a : b ;
+ }
+
+ char max(char a, char b)
+ {
+ return (a>b) ? b : a ;
+ }
+
+ char add(char a, char b)
+ {
+ return a+b;
+ }
+
+ char mult(char a, char b)
+ {
+ return a*b;
+ }
+
+ void loop( void (*init)(void *) , void (*step)(void *) ,void *result)
+ {
+ unsigned long i;
+ i=0;
+ init(result);
+
+ while(i<IOTEST_SIZE)
+ {
+ step(result);
+ i++;
+ }
+ }
+
+ extern void testA(void), testB(void), testC(void);
+ int main() {
+ testarray = (char*)malloc(IOTEST_SIZE);
+ testA(); testB(); testC();
+ return 0;
+ }
+
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.h
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.h:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.h Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,29 ----
+
+
+ struct global_result
+ {
+ char min;
+ char max;
+ char add;
+ char mult;
+ };
+
+ void initarray(void);
+
+ char array(unsigned long i);
+
+ unsigned long getac(void);
+
+ void setac(unsigned long i);
+
+ char min(char a, char b);
+
+ char max(char a, char b);
+
+ char add(char a, char b);
+
+ char mult(char a, char b);
+
+ void loop(void (*init)(void *) , void (*step)(void *) ,void *result);
+
+
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.readme
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.readme:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtest.readme Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,41 ----
+
+ Modern computer use multiple kinds of memory.
+
+ There is CPU registers, CPU cash , intern memory and extern memory.
+
+ If the CPU wants to read/write to memory.
+ It have to do it whit different speed to different kinds of memory.
+
+ CPU registers are fast.
+ and extern memory is slowest.
+
+ Data moves between this kinds of memory as blocks of data.
+
+ Between CPU registers and CPU cash in 16,32 or 64 bit blocks.
+
+ Between CPU cash and intern memory in 16,32 or 64 bit blocks.
+
+ Between intern memory and extern memory in memory pages (4096 bytes) blocks.
+
+ Given this a strategy for optimisation could be that we try to minimise
+ the number of times a block get moved from one kind of memory to another.
+
+ To demonstrate and to test optimisers I have made the following 3 programs.
+
+ The all solve the same problem but are using memory on 3 different ways.
+ So a good optimiser should make them all run equal fast.
+
+ The problem is to take a big array of numbers and then accumulate 4 numbers
+ min, max, sum and product.
+
+ testA is the fast version.
+ It accumulate all values in one parse.
+
+ testB is slower
+ It accumulate all values in 4 parses.
+
+ testC is slowest.
+ It also accumulate the values in 4 parses.
+ But it don't start at element 0 and go to element n-1 but it jumps around
+ in the array.
+
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestA.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestA.c:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestA.c Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,63 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ #include <stdio.h>
+ #include "IOtest.h"
+
+ /* fast version */
+
+ void initA(struct global_result *res)
+ {
+ setac(0);
+ res->min=255;
+ res->max=0;
+ res->add=0;
+ res->mult=1;
+ }
+
+ void stepA(struct global_result *res)
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ res->min=min(res->min,t);
+ res->max=max(res->max,t);
+ res->add=add(res->add,t);
+ res->mult=mult(res->mult,t);
+ i=getac();
+ i++;
+ setac(i);
+ }
+
+ void testA()
+ {
+ struct global_result res;
+
+ initarray();
+
+ loop((void (*)(void *))&initA,(void (*)(void *))&stepA,&res);
+
+ printf("A %d min %d max %d add %d mult \n",res.min,res.max,res.add,res.mult);
+
+ }
+
+
+
+
+
+
+
+
+
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestB.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestB.c:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestB.c Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,115 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ #include <stdio.h>
+ #include "IOtest.h"
+
+ /* slow version */
+
+ void initminB(char *res)
+ {
+ setac(0);
+ *res=255;
+ }
+
+ void initmaxB(char *res)
+ {
+ setac(0);
+ *res=0;
+ }
+
+ void initaddB(char *res)
+ {
+ setac(0);
+ *res=0;
+ }
+
+ void initmultB(char *res)
+ {
+ setac(0);
+ *res=1;
+ }
+
+
+ void stepminB(char *res)
+ /* {{{ */
+
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=min(*res,t);
+ i=getac()+1;
+ setac(i);
+ }
+
+ /* }}} */
+
+ void stepmaxB(char *res)
+ /* {{{ */
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=max(*res,t);
+ i=getac()+1 ;
+ setac(i);
+ }
+ /* }}} */
+
+ void stepaddB(char *res)
+ /* {{{ */
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=add(*res,t);
+ i=getac()+1;
+ setac(i);
+ }
+ /* }}} */
+
+ void stepmultB(char *res)
+ /* {{{ */
+
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=mult(*res,t);
+ i=getac()+1;
+ setac(i);
+ }
+
+ /* }}} */
+
+
+ void testB()
+ {
+ struct global_result res;
+
+ initarray();
+
+ loop((void (*)(void *))&initminB,(void (*)(void *))&stepminB,&(res.min));
+
+ loop((void (*)(void *))&initmaxB,(void (*)(void *))&stepmaxB,&(res.max));
+
+ loop((void (*)(void *))&initaddB,(void (*)(void *))&stepaddB,&(res.add));
+
+ loop((void (*)(void *))&initmultB,(void (*)(void *))&stepmultB,&(res.mult));
+
+ printf("B %d min %d max %d add %d mult \n",res.min,res.max,res.add,res.mult);
+
+ }
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestC.c
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestC.c:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/IOtestC.c Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,115 ----
+
+ /****
+ Copyright (C) 1996 McGill University.
+ Copyright (C) 1996 McCAT System Group.
+ Copyright (C) 1996 ACAPS Benchmark Administrator
+ benadmin at acaps.cs.mcgill.ca
+
+ This program is free software; you can redistribute it and/or modify
+ it provided this copyright notice is maintained.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ ****/
+
+ #include <stdio.h>
+ #include "IOtest.h"
+
+ /* slow version */
+
+ static void initminB(char *res)
+ {
+ setac(0);
+ *res=255;
+ }
+
+ static void initmaxB(char *res)
+ {
+ setac(0);
+ *res=0;
+ }
+
+ static void initaddB(char *res)
+ {
+ setac(0);
+ *res=0;
+ }
+
+ static void initmultB(char *res)
+ {
+ setac(0);
+ *res=1;
+ }
+
+
+ static void stepminB(char *res)
+ /* {{{ */
+
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=min(*res,t);
+ i=getac()+4097;
+ setac(i);
+ }
+
+ /* }}} */
+
+ static void stepmaxB(char *res)
+ /* {{{ */
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=max(*res,t);
+ i=getac()+4097 ;
+ setac(i);
+ }
+ /* }}} */
+
+ static void stepaddB(char *res)
+ /* {{{ */
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=add(*res,t);
+ i=getac()+4097;
+ setac(i);
+ }
+ /* }}} */
+
+ static void stepmultB(char *res)
+ /* {{{ */
+
+ {
+ register char t;
+ unsigned long i;
+ t=array(getac());
+ *res=mult(*res,t);
+ i=getac()+4097;
+ setac(i);
+ }
+
+ /* }}} */
+
+
+ void testC()
+ {
+ struct global_result res;
+
+ initarray();
+
+ loop((void (*)(void *))&initminB,(void (*)(void *))&stepminB,&(res.min));
+
+ loop((void (*)(void *))&initmaxB,(void (*)(void *))&stepmaxB,&(res.max));
+
+ loop((void (*)(void *))&initaddB,(void (*)(void *))&stepaddB,&(res.add));
+
+ loop((void (*)(void *))&initmultB,(void (*)(void *))&stepmultB,&(res.mult));
+
+ printf("C %d min %d max %d add %d mult \n",res.min,res.max,res.add,res.mult);
+
+ }
Index: llvm/test/Programs/MultiSource/McCat-12-IOtest/Makefile
diff -c /dev/null llvm/test/Programs/MultiSource/McCat-12-IOtest/Makefile:1.1
*** /dev/null Mon May 12 13:47:33 2003
--- llvm/test/Programs/MultiSource/McCat-12-IOtest/Makefile Mon May 12 13:47:22 2003
***************
*** 0 ****
--- 1,6 ----
+ LEVEL = ../../../..
+ PROG = iotest
+ #LDFLAGS = -lm
+ #RUN_OPTIONS += trie.in1
+ include ../Makefile.multisrc
+
More information about the llvm-commits
mailing list