init repo

This commit is contained in:
RomanRom2 committed 2025-01-28 19:17:01 +03:00
commit 90e6151613
3260 files changed
+3745062

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
CC=../../build/glcc
ROM=dev7
MAP=64k,hionly
DEFS=
CFLAGS=-rom=$(ROM) -map=$(MAP) ${DEFS} -Dprintf=mincprintf
PGMS=sieve0.gt1 sieve1.gt1
all: $(PGMS)
sieve0.gt1: sieve0.c
${CC} ${CFLAGS} sieve0.c -o $@
sieve1.gt1: sieve1.c
${CC} ${CFLAGS} sieve1.c -o $@
clean:
-rm *.gt1 *.s *.frg *.prf *-prof.txt
sieve0-sim.gt1: sieve0.c Makefile
${CC} -rom=${ROM} -map=sim,hionly ${DEFA} $< -o $@ --frags > sieve0-sim.frg
sieve1-sim.gt1: sieve1.c Makefile
${CC} -rom=${ROM} -map=sim,hionly ${DEFS} $< -o $@ --frags > sieve1-sim.frg
sieve0-prof.txt: sieve0-sim.gt1
gtsim -rom ../../gigatron/roms/${ROM}.rom -vmode 1975 -prof sieve0-sim.prf sieve0-sim.gt1
gtprof sieve0-sim.prf sieve0-sim.frg > sieve0-prof.txt
sieve1-prof.txt: sieve1-sim.gt1
gtsim -rom ../../gigatron/roms/${ROM}.rom -vmode 1975 -prof sieve1-sim.prf sieve1-sim.gt1
gtprof sieve1-sim.prf sieve1-sim.frg > sieve1-prof.txt
+59
View File
@@ -0,0 +1,59 @@
#include <stdio.h>
#include <gigatron/sys.h>
#include <gigatron/libc.h>
#include <time.h>
#ifndef TIMER
# define TIMER 1
#endif
#ifndef PRINT
# define PRINT 1
#endif
/** This is the pristine C program of the sieve benchmark.
The only additions are the #include directives above
and the timing code enabled by the preprocessor symbol TIMER. **/
#define true 1
#define false 0
#define size 8190
#define sizepl 8191
char flags[sizepl];
main() {
int i, prime, k, count, iter;
#if TIMER
unsigned int ticks = _clock();
#endif
#if PRINT
printf("10 iterations\n");
#endif
for (iter = 1; iter <= 10; iter ++) {
count=0 ;
for (i = 0; i <= size; i++)
flags[i] = true;
for (i = 0; i <= size; i++) {
if (flags[i]) {
prime = i + i + 3;
k = i + prime;
while (k <= size) {
flags[k] = false;
k += prime;
}
count = count + 1;
}
}
}
#if PRINT
printf("\n%d primes", count);
#endif
#if TIMER
ticks = _clock() - ticks;
printf("\n%d %d/60 seconds", ticks/60, ticks % 60);
#endif
}
/* Local Variables: */
/* mode: c */
/* c-basic-offset: 4 */
/* indent-tabs-mode: () */
/* End: */
+65
View File
@@ -0,0 +1,65 @@
#include <stdio.h>
#include <string.h>
#include <gigatron/sys.h>
#include <gigatron/libc.h>
#include <time.h>
#ifndef TIMER
# define TIMER 1
#endif
#ifndef MEMSET
# define MEMSET 1
#endif
/** This is a minor modification of the pristine C program of the
sieve benchmark. Loop conditions and certain expressions have
been made Gigatron friendly. Table clearing is conditionally done
with memset (which is proper ANSI C 1989). */
#define true 1
#define false 0
#define size 8190
#define sizepl 8191
char flags[sizepl];
main() {
int i, prime, k, count, iter;
#if TIMER
unsigned int ticks = _clock();
#endif
printf("10 iterations\n");
for (iter = 1; iter <= 10; iter ++) {
count = 0;
#if MEMSET
/* memset is a legit ANSI C 1989 function
and clears up to 32 bytes per scanline */
memset(flags, true, sizepl);
#else
/* simple pointer loop */
{ char *p = flags; while(p != flags+sizepl) *p++ = true; }
#endif
for (i = 0; i != sizepl; i++) {
if (flags[i]) {
prime = i + i + 3;
k = prime + i;
while (size >= k) {
flags[k] = false;
k += prime;
}
count = count + 1;
}
}
}
printf("\n%d primes", count);
#if TIMER
ticks = _clock() - ticks;
printf("\n%d %d/60 seconds", ticks/60, ticks % 60);
#endif
}
/* Local Variables: */
/* mode: c */
/* c-basic-offset: 4 */
/* indent-tabs-mode: () */
/* End: */