mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-12-24 15:29:29 +00:00
Add Sieve of Eratosthenesq benchmark
This commit is contained in:
parent
b557c489cc
commit
0c0f8b6fa8
@ -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
|
||||
|
66
src/samplesrc/sieve.pla
Normal file
66
src/samplesrc/sieve.pla
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user