From 0c0f8b6fa8b15f2ccab46e5b2d9512fdef69ea07 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Mon, 7 Jul 2014 20:48:48 -0700 Subject: [PATCH] Add Sieve of Eratosthenesq benchmark --- src/makefile | 7 ++++- src/samplesrc/sieve.pla | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/samplesrc/sieve.pla diff --git a/src/makefile b/src/makefile index 3ed283f..b8fbc84 100644 --- a/src/makefile +++ b/src/makefile @@ -6,6 +6,7 @@ PLVM02 = PLASMA.SYSTEM\#FF2000 PLVM03 = SOS.INTERP\#050000 CMD = CMD\#FF2000 ROD = ROD\#FE1000 +SIEVE = SIEVE\#FE1000 HELLO = HELLO\#FE1000 HGR1 = HGR1\#FE1000 HGR1TEST= HGR1TEST\#FE1000 @@ -31,7 +32,7 @@ TXTTYPE = .TXT #SYSTYPE = \#FF2000 #TXTTYPE = \#040000 -all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ROD) $(HGR1) +all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(PROFILE) $(ROD) $(SIEVE) $(HGR1) clean: -rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) @@ -84,6 +85,10 @@ $(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM) ./$(PLASM) -AM < samplesrc/rod.pla > samplesrc/rod.a acme --setpc 4094 -o $(ROD) samplesrc/rod.a +$(SIEVE): samplesrc/sieve.pla $(PLVM02) $(PLASM) + ./$(PLASM) -AM < samplesrc/sieve.pla > samplesrc/sieve.a + acme --setpc 4094 -o $(SIEVE) samplesrc/sieve.a + $(PROFILE): samplesrc/profile.pla $(PLVM02) $(PLASM) m4 -I inc < samplesrc/profile.pla | ./$(PLASM) -AM > samplesrc/profile.a acme --setpc 4094 -o $(PROFILE) samplesrc/profile.a diff --git a/src/samplesrc/sieve.pla b/src/samplesrc/sieve.pla new file mode 100644 index 0000000..1c4a2db --- /dev/null +++ b/src/samplesrc/sieve.pla @@ -0,0 +1,66 @@ +;10 S=8190: DIM F(8191): N=0 +;20 FOR I=0 TO S: F(I)=1: NEXT I +;30 FOR I=0 TO S +; IF F(I)=0 THEN 80 +;40 P=I+I+3: K=I+P +;50 IF K>S THEN 70 +;60 F(K)=0: K=K+P +; GOTO 50 +;70 N=N+1: REM PRINT P;" "; +;80 NEXT I +;90 PRINT: PRINT N;" PRIMES": END + +import STDLIB + predef syscall, call, memset, getc, putc, puts, putln + byte MACHID +end + +const FALSE = 0 +const TRUE = !FALSE +const maxPrime = 8190 +const numPrimes = maxPrime+1 + +byte flag[numPrimes] +byte iter +word prime, i, k, count +byte strPrimes[] = " primes.\n" + +def beep + return putc(7) +end + +def puti(i) + if i < 0 + putc('-') + i = -i + fin + if i < 10 + putc(i + '0') + else + puti(i / 10) + putc(i % 10 + '0') + fin +end + +beep +for iter = 1 to 10 + memset(@flag, numPrimes, TRUE) + count = 0 + for i = 0 to maxPrime + if flag[i] + prime = i + i + 3 + k = i + prime + while k <= maxPrime + flag[k] = FALSE + k = k + prime + loop + count = count + 1 + ;puti(prime) + ;putln + fin + next +next +beep +puti(count) +puts(@strPrimes) +done \ No newline at end of file