├── .gitignore ├── COPYING ├── Makefile ├── Makefile.docker ├── Makefile.linux ├── Makefile.linux.bak ├── Makefile.mac ├── buildgraph.c ├── combustion.c ├── distribution.c ├── dockerfile ├── dvm.c ├── graph.c ├── h ├── buildgraph.h ├── combustion.h ├── distribution.h ├── dvm.h ├── gml_parser.h ├── gml_scanner.h ├── graph.h ├── io.h ├── lambdastar.h ├── mydefs.h ├── parser.tab.h ├── symbolic.h └── var.h ├── io.c ├── les.fl ├── les.fl.bak ├── main.c ├── parser.output ├── parser.tab.c ├── parser.tab.h ├── parser.y ├── pelcrexamples ├── .gitignore ├── 10square.plcr ├── 121triple_f.plcr ├── 200checksum.plcr ├── 20checksum.plcr ├── 20square.plcr ├── 2I.plcr ├── 2dd4.plcr ├── 4checksum.plcr ├── 4product.plcr ├── 4square.plcr ├── 5square.plcr ├── BruteTest.plcr ├── EAL ├── EAL.gml ├── brute_force.plcr ├── brute_force_plcr ├── d2.plcr ├── d3triple_f.plcr ├── d4.plcr ├── d4addone.plcr ├── d4checksum.plcr ├── d4double_f.plcr ├── d4triple_f.plcr ├── dcm2005.plcr ├── dd2.plcr ├── dd3.plcr ├── dd4.gml ├── dd4.plcr ├── dd5.plcr ├── difficult.plcr ├── doublelist.plcr ├── explosions ├── extsucc.plcr ├── fact.plcr ├── fibonacci.plcr ├── fivesquare.plcr ├── foursquare.plcr ├── jfig2.plcr ├── k2i.plcr ├── kdd.plcr ├── ki.plcr ├── longid.plcr ├── matrix.plcr ├── matrix2.plcr ├── matrixnew.plcr ├── pure.plcr ├── s0.plcr ├── s1.plcr ├── scan.plcr ├── sharedfunccalls.plcr ├── succ.plcr └── tensquare.plcr ├── print.c ├── read_back.c ├── shared.c └── symbolic.c /.gitignore: -------------------------------------------------------------------------------- 1 | /buildgraph.o 2 | /combustion.mac 3 | /combustion.o 4 | /distribution.o 5 | /dvm.o 6 | /graph.o 7 | /io.o 8 | *.yy.o 9 | /main.o 10 | /print.o 11 | /read_back.o 12 | /run.0.log 13 | /run.1.log 14 | /runold.0.log 15 | /runold.1.log 16 | /symbolic.o 17 | /y.tab.o 18 | /Makefile 19 | /lex.yy.c 20 | /y.output 21 | /y.tab.c 22 | /y.tab.h 23 | /.vscode/c_cpp_properties.json 24 | *.log 25 | /Makefile.head 26 | /.vscode/ 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.head 2 | 3 | ################ common part 4 | 5 | OBJECTS = parser.tab.o lex.yy.o read_back.o dvm.o io.o graph.o symbolic.o distribution.o print.o main.o buildgraph.o combustion.o 6 | PARSERSRC = lex.yy.c parser.tab.c 7 | SRCS = lex.yy.c parser.tab.c $(COMPILINGRDIR)read_back.c $(COMPILINGRDIR)dvm.c $(COMPILINGRDIR)io.c $(COMPILINGRDIR)graph.c $(COMPILINGRDIR)symbolic.c $(COMPILINGRDIR)distribution.c $(COMPILINGRDIR)print.c $(COMPILINGRDIR)main.c $(COMPILINGRDIR)buildgraph.c $(COMPILINGRDIR)combustion.c 8 | 9 | BASETYPE='long long' 10 | TESTFILE = "dd4.plcr" 11 | 12 | RUN1= echo "\#setdir \"$(PEXDIR)\" ; \#open \"$(TESTFILE)\"" 13 | RUN = $(MPIR_HOME)/bin/mpirun -np $(NP) $(EXECS) -- -I ciccio -loop 10000000 -o GML/prova -v -t 14 | RUNTEST = $(RUN1)|$(RUN) 15 | LIB_PATH = 16 | LIB_LIST = -ldl -lm -ll -lc 17 | CFLAGS =$(ARCHFLAGS) $(OPTFLAGS) 18 | CCFLAGS = $(CFLAGS) 19 | FFLAGS = $(OPTFLAGS) 20 | 21 | default: gcombustion 22 | 23 | all: default 24 | 25 | lex.yy.c: $(COMPILINGRDIR)les.fl 26 | $(LEX) $(COMPILINGRDIR)les.fl 27 | 28 | y.tab.c: $(COMPILINGRDIR)parser.y 29 | $(YACC) -d -v $(COMPILINGRDIR)parser.y -b y 30 | 31 | objects: $(SRCS) 32 | $(CC) $(CFLAGS) $(OSFLAGS) -c $(SRCS) 33 | 34 | gcombustion: y.tab.c objects 35 | $(CLINKER) $(ARCHFLAGS) $(OPTFLAGS) $(OSFLAG) -o $(EXECS) $(OBJECTS) $(LIB_PATH) $(LIB_LIST) 36 | 37 | go: NP=1 38 | go: 39 | $(RUN) 40 | 41 | go2: NP=2 42 | go2: 43 | $(RUN) 44 | 45 | test: NP=1 46 | test: 47 | $(RUNTEST) 48 | 49 | test2: NP=2 50 | test2: 51 | $(RUNTEST) 52 | 53 | test4: NP=4 54 | test4: 55 | $(RUNTEST) 56 | 57 | clean: 58 | /bin/rm -f y.output y.tab.h y.tab.c lex.yy.c *.o run.*.log core combustion combustion.home combustion.ultra combustion.linux combustion.capital combustion.mac *.log combustion*.tex *.idx *.aux *.scn combustion*.dvi *.toc *~ DAT/*.* GML/* h/*~ ./Crypto/*.o ./Crypto/*.so *.so 59 | 60 | linux: 61 | rm Makefile.head 62 | ln -s Makefile.linux Makefile.head 63 | make all 64 | 65 | mac: 66 | rm Makefile.head 67 | ln -s Makefile.mac Makefile.head 68 | make all 69 | 70 | docker: 71 | rm Makefile.head 72 | ln -s Makefile.docker Makefile.head 73 | make all 74 | 75 | home: gcombustion 76 | -------------------------------------------------------------------------------- /Makefile.docker: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | ALL: default 3 | ##### User configurable options ##### 4 | #TEST 5 | 6 | ARCH = LINUX 7 | BASETYPE = 'long long' 8 | MPIR_HOME = /usr/lib64/openmpi 9 | CC = $(MPIR_HOME)/bin/mpicc 10 | CCP = $(MPIR_HOME)/bin/mpiCC 11 | CLINKER = $(CC) 12 | CCC = $(MPIR_HOME)/bin/mpiCC 13 | COMPILINGRDIR = ./ 14 | CCLINKER = $(CCC) 15 | PROFILING = $(PMPILIB) 16 | #OPTFLAGS = -DDEBUG -DWDEBUG -DMEMDEBUG -Wall -g -pg 17 | OPTFLAGS = -D_DEBUG -DWDEBUG -DMEMDEBUG -DUSERTYPE=$(BASETYPE) -Wall -g -Wl,-export-dynamic -I $(COMPILINGRDIR)h -I . 18 | #-mpilog -mpitrace -mpianim -02 -DWDEBUG 19 | #OPTFLAGS = -DWDEBUG -DMEMDEBUG -g -pg 20 | 21 | COMPILINGRDIR = ./ 22 | 23 | ########per il parser 24 | LEX= lex 25 | YACC = bison 26 | 27 | ### End User configurable options ### 28 | OSFLAGS = -DLINUX 29 | CFLAGS = $(OPTFLAGS) 30 | CCFLAGS = $(CFLAGS) 31 | FFLAGS = $(OPTFLAGS) 32 | EXECS = combustion.docker 33 | 34 | -------------------------------------------------------------------------------- /Makefile.linux: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | ALL: default 3 | ##### User configurable options ##### 4 | 5 | ARCH = LINUX 6 | BASETYPE = 'long long' 7 | MPIR_HOME = /usr/lib64/openmpi 8 | CC = $(MPIR_HOME)/bin/mpicc 9 | CCP = $(MPIR_HOME)/bin/mpiCC 10 | CLINKER = $(CC) 11 | CCC = $(MPIR_HOME)/bin/mpiCC 12 | COMPILINGRDIR = ./ 13 | CCLINKER = $(CCC) 14 | PROFILING = $(PMPILIB) 15 | #OPTFLAGS = -DDEBUG -DWDEBUG -DMEMDEBUG -Wall -g -pg 16 | OPTFLAGS = -D_DEBUG -DWDEBUG -DMEMDEBUG -DUSERTYPE=$(BASETYPE) -Wall -g -Wl,-export-dynamic -I $(COMPILINGRDIR)h -I . 17 | #-mpilog -mpitrace -mpianim -02 -DWDEBUG 18 | #OPTFLAGS = -DWDEBUG -DMEMDEBUG -g -pg 19 | 20 | ########per il parser 21 | LEX= lex 22 | YACC = bison 23 | 24 | ### End User configurable options ### 25 | OSFLAGS = -DLINUX 26 | CFLAGS = $(OPTFLAGS) 27 | CCFLAGS = $(CFLAGS) 28 | FFLAGS = $(OPTFLAGS) 29 | OBJECTS = read_back.o dvm.o io.o graph.o symbolic.o distribution.o print.o main.o buildgraph.o combustion.o lex.yy.o 30 | SRCS = read_back.c dvm.c io.c graph.c symbolic.c distribution.c print.c parser.tab.c main.c buildgraph.c combustion.c lex.yy.c 31 | PARSERSRC = lex.yy.c parser.tab.c 32 | EXECS = combustion.linux 33 | 34 | -------------------------------------------------------------------------------- /Makefile.linux.bak: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | ALL: default 3 | ##### User configurable options ##### 4 | 5 | ARCH = LINUX 6 | BASETYPE = 'long long' 7 | MPIR_HOME = /usr/lib64/openmpi 8 | CC = $(MPIR_HOME)/bin/mpicc 9 | CCP = $(MPIR_HOME)/bin/mpiCC 10 | CLINKER = $(CC) 11 | CCC = $(MPIR_HOME)/bin/mpiCC 12 | COMPILINGRDIR = ./ 13 | CCLINKER = $(CCC) 14 | PROFILING = $(PMPILIB) 15 | #OPTFLAGS = -DDEBUG -DWDEBUG -DMEMDEBUG -Wall -g -pg 16 | OPTFLAGS = -D_DEBUG -DWDEBUG -DMEMDEBUG -DUSERTYPE=$(BASETYPE) -Wall -g -Wl,-export-dynamic -I $(COMPILINGRDIR)h -I . 17 | #-mpilog -mpitrace -mpianim -02 -DWDEBUG 18 | #OPTFLAGS = -DWDEBUG -DMEMDEBUG -g -pg 19 | 20 | ########per il parser 21 | LEX= lex 22 | YACC = bison 23 | 24 | ### End User configurable options ### 25 | OSFLAGS = -DLINUX 26 | CFLAGS = $(OPTFLAGS) 27 | CCFLAGS = $(CFLAGS) 28 | FFLAGS = $(OPTFLAGS) 29 | OBJECTS = read_back.o dvm.o io.o graph.o symbolic.o distribution.o print.o main.o buildgraph.o combustion.o lex.yy.o 30 | SRCS = read_back.c dvm.c io.c graph.c symbolic.c distribution.c print.c parser.tab.c main.c buildgraph.c combustion.c lex.yy.c 31 | PARSERSRC = lex.yy.c parser.tab.c 32 | EXECS = combustion.linux 33 | RUN = $(MPIR_HOME)/bin/mpirun -np 1 $(EXECS) -- -I ciccio -loop 100000 -v -t -o GML/ciccio 34 | LIB_PATH = 35 | LIB_LIST = -ldl -lm -ll -lfl -lpthread -lc 36 | 37 | default: gcombustion 38 | 39 | all: default 40 | 41 | parser.tab.c: parser.y 42 | $(YACC) -d -v parser.y 43 | 44 | objects: $(SRCS) 45 | $(CC) $(CFLAGS) $(OSFLAGS) -c $(SRCS) 46 | 47 | gcombustion: objects parser.tab.c 48 | $(CLINKER) $(OPTFLAGS) $(OSFLAG) -o $(EXECS) $(OBJECTS) parser.tab.o $(LIB_PATH) $(LIB_LIST) 49 | 50 | dll: crypt shared 51 | 52 | shared: 53 | /usr/bin/gcc -c $(OPTFLAGS) shared.c 54 | ld -shared shared.o -o shared.so 55 | 56 | crypt: 57 | /usr/bin/gcc -c $(OPTFLAGS) ./Crypto/crypto.c -o ./Crypto/crypto.o 58 | ld -shared ./Crypto/crypto.o -o ./Crypto/crypto.so 59 | 60 | lambdastar: symbolic3.o lambdastar.c 61 | $(CLINKER) $(OPTFLAGS) $(OSFLAG) -o lambdastar.cantor symbolic3.o lambdastar.c $(LIB_PATH) $(LIB_LIST) -lm 62 | 63 | lex.yy.c: les.fl 64 | $(LEX) les.fl 65 | 66 | parser: $(PARSERSRC) 67 | $(CC) lex.yy.c parser.tab.c dvm.c io.c graph.c symbolic4.c distribution.c -ll -lfl -o parser 68 | 69 | go: 70 | $(RUN) 71 | 72 | clean: 73 | /bin/rm -f y.output y.tab.h y.tab.c lex.yy.c *.o run.*.log core combustion combustion.home combustion.ultra combustion.linux combustion.capital combustion.mac *.log combustion*.tex *.idx *.aux *.scn combustion*.dvi *.toc *~ DAT/*.* GML/* h/*~ ./Crypto/*.o ./Crypto/*.so *.so 74 | 75 | 76 | sp: rm Makefile 77 | ln -s Makefile.sp Makefile 78 | make all 79 | 80 | ultra: 81 | rm Makefile 82 | ln -s Makefile.ultra Makefile 83 | make all 84 | 85 | capital: 86 | rm Makefile 87 | ln -s Makefile.capital Makefile 88 | make all 89 | 90 | parsifal: 91 | rm Makefile 92 | ln -s Makefile.parsifal Makefile 93 | make all 94 | 95 | linux: 96 | rm Makefile 97 | ln -s Makefile.linux Makefile 98 | make all 99 | 100 | mac: 101 | rm Makefile 102 | ln -s Makefile.mac Makefile 103 | make all 104 | 105 | home: gcombustion 106 | -------------------------------------------------------------------------------- /Makefile.mac: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | ALL: default 3 | ##### User configurable options ##### 4 | PEXDIR = pelcrexamples 5 | ARCH = LINUX 6 | #MPIR_HOME = /mpi-share/current-mpi 7 | MPIR_HOME = /usr/local 8 | CC=$(MPIR_HOME)/bin/mpicc 9 | CCP = $(MPIR_HOME)/bin/mpiCC 10 | CLINKER = $(CC) 11 | CCC = $(MPIR_HOME)/bin/mpiCC 12 | CCLINKER = $(CCC) 13 | PROFILING = $(PMPILIB) 14 | #OPTFLAGS = -DDEBUG -DWDEBUG -DMEMDEBUG -Wall -g -pg 15 | #OPTFLAGS = -D_DEBUG -DUSERTYPE=$(BASETYPE) -Wall -bind_at_load 16 | 17 | COMPILINGRDIR = ./ 18 | #OPTFLAGS = -D_DEBUG -Wall 19 | OPTFLAGS=-D_DEBUG -DUSERTYPE=$(BASETYPE) -I$(COMPILINGRDIR)h -I. 20 | 21 | ARCHFLAGS=-g -fstrict-aliasing -mtune=x86-64 22 | #-mpilog -mpitrace -mpianim -02 -DWDEBUG 23 | #OPTFLAGS = -DWDEBUG -DMEMDEBUG -g -pg 24 | 25 | ########per il parser 26 | LEX=flex 27 | YACC=bison 28 | 29 | ### End User configurable options ### 30 | #OSFLAGS = -DLINUX 31 | OSFLAGS = 32 | 33 | OBJECTS = parser.tab.o lex.yy.o read_back.o dvm.o io.o graph.o symbolic.o distribution.o print.o main.o buildgraph.o combustion.o 34 | 35 | SRCS = lex.yy.c parser.tab.c $(COMPILINGRDIR)read_back.c $(COMPILINGRDIR)dvm.c $(COMPILINGRDIR)io.c $(COMPILINGRDIR)graph.c $(COMPILINGRDIR)symbolic.c $(COMPILINGRDIR)distribution.c $(COMPILINGRDIR)print.c $(COMPILINGRDIR)main.c $(COMPILINGRDIR)buildgraph.c $(COMPILINGRDIR)combustion.c 36 | EXECS = combustion.mac 37 | 38 | 39 | -------------------------------------------------------------------------------- /dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | FROM centos:latest 3 | RUN cat /etc/centos-release 4 | RUN cd /etc/yum.repos.d ;sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*;sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* 5 | 6 | RUN dnf -y update 7 | RUN dnf -y install dnf-plugins-core 8 | RUN dnf -y config-manager --set-enabled powertools 9 | 10 | RUN dnf -y install git wget gcc gdb make openmpi openmpi-devel bison flex bison-devel flex-devel strace 11 | RUN yum -y debuginfo-install libevent-2.1.8-5.el8.x86_64 openmpi-4.1.1-2.el8.x86_64 openmpi-devel-4.1.1-2.el8.x86_64 openssl-libs-1.1.1k-5.el8_5.x86_64 zlib-1.2.11-17.el8.x86_64 12 | COPY . /app 13 | RUN cd /app ; make docker ; make 14 | RUN make /app 15 | RUN useradd -ms /bin/bash pelcr 16 | RUN chown -R pelcr /app 17 | USER pelcr 18 | WORKDIR /app 19 | 20 | CMD bash 21 | -------------------------------------------------------------------------------- /dvm.c: -------------------------------------------------------------------------------- 1 | /* Manager of global address space of memory for graph distributed allocation 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #ifdef SOLARIS 25 | #include 26 | #endif 27 | #include 28 | #include 29 | #include 30 | #ifdef MPE_GRAPH 31 | #include 32 | #endif 33 | #include 34 | 35 | #include 36 | // 37 | //#include "h/mydefs.h" 38 | //#include "h/symbolic.h" 39 | //#include "h/graph.h" 40 | //#include "h/combustion.h" 41 | //#include "h/io.h" 42 | //#include "h/buildgraph.h" 43 | //#include "h/dvm.h" 44 | #include "h/var.h" 45 | #define INIT_TABLE_SIZE 239 46 | 47 | void*safemalloc(length) 48 | int length; 49 | { 50 | char*ptr; 51 | 52 | if(length<=0) 53 | length= 1; 54 | 55 | ptr= (char*)malloc((size_t)length); 56 | if(ptr==(char*)0) 57 | { 58 | fprintf(stderr,"malloc of %d bytes failed. Exiting\n",length); 59 | exit(1); 60 | } 61 | return ptr; 62 | } 63 | 64 | HashTable*table_init(HashTable *table) 65 | { 66 | table->elements= 0; 67 | table->size= INIT_TABLE_SIZE; 68 | table->table= safemalloc(INIT_TABLE_SIZE*sizeof(HashEntry*)); 69 | table->last= NULL; 70 | memset(table->table,0,INIT_TABLE_SIZE*sizeof(HashEntry*)); 71 | 72 | return table; 73 | } 74 | 75 | unsigned long 76 | hash_ikey(key) 77 | unsigned long key; 78 | { 79 | unsigned long h= 0,g; 80 | int i; 81 | char skey[sizeof(unsigned long)]; 82 | 83 | memcpy(skey,&key,sizeof(unsigned long)); 84 | for(i= 0;i>24; 88 | h&= ~g; 89 | } 90 | return h; 91 | } 92 | 93 | int 94 | table_iget (HashTable*table,unsigned long key,node**address) 95 | /* table_iget(table,key,address) */ 96 | /* HashTable *table; */ 97 | /* unsigned long key; */ 98 | /* node**address; */ 99 | { 100 | unsigned long hkey; 101 | HashEntry*entry; 102 | 103 | hkey= hash_ikey(key)%table->size; 104 | entry= table->table[hkey]; 105 | while(entry!=NULL){ 106 | if(entry->key==key){ 107 | *address= entry->address; 108 | return 1; 109 | } 110 | entry= entry->next; 111 | } 112 | return 0; 113 | } 114 | 115 | void rebuild_itable(HashTable*table) 116 | /* rebuild_itable(table) */ 117 | /* HashTable*table; */ 118 | { 119 | HashTable newtable; 120 | HashEntry*entry; 121 | int i; 122 | 123 | extern void table_iput(); 124 | extern void table_idestroy(); 125 | 126 | newtable.last= NULL; 127 | newtable.elements= 0; 128 | newtable.size= table->size*2; 129 | newtable.table= safemalloc(newtable.size*sizeof(HashEntry*)); 130 | memset(newtable.table,0,newtable.size*sizeof(HashEntry*)); 131 | for(i= 0;isize;i++){ 132 | entry= table->table[i]; 133 | while(entry){ 134 | table_iput(&newtable,entry->key,entry->address); 135 | entry= entry->next; 136 | } 137 | } 138 | table_idestroy(table); 139 | table->elements= newtable.elements; 140 | table->size= newtable.size; 141 | table->table= newtable.table; 142 | } 143 | 144 | void table_iput(HashTable*table,unsigned long key,node*address) 145 | /* table_iput(table,key,address) */ 146 | /* HashTable*table; */ 147 | /* unsigned long key; */ 148 | /* node*address; */ 149 | { 150 | unsigned long hkey; 151 | HashEntry*nentry; 152 | 153 | nentry= safemalloc(sizeof(HashEntry)); 154 | nentry->key= key; 155 | nentry->address= address; 156 | hkey= hash_ikey(key)%table->size; 157 | 158 | if(table->table[hkey]!=NULL){ 159 | nentry->next= table->table[hkey]; 160 | table->table[hkey]= nentry; 161 | }else{ 162 | nentry->next= NULL; 163 | table->table[hkey]= nentry; 164 | } 165 | table->elements++; 166 | 167 | nentry->nptr= NULL; 168 | nentry->pptr= table->last; 169 | if(table->last) 170 | table->last->nptr= nentry; 171 | table->last= nentry; 172 | 173 | if(table->elements>(table->size*3)/2){ 174 | #ifdef _DEBUG 175 | DEBUG_HASH printf("rebuilding hash table...\n"); 176 | #endif 177 | rebuild_itable(table); 178 | } 179 | } 180 | HashEntry*delete_fromilist(HashTable*table,HashEntry*entry,unsigned long key) 181 | 182 | /* HashEntry* */ 183 | /* delete_fromilist(table,entry,key) */ 184 | /* HashTable*table; */ 185 | /* HashEntry*entry; */ 186 | /* unsigned long key; */ 187 | { 188 | HashEntry*next; 189 | 190 | if(entry==NULL)return NULL; 191 | if(entry->key==key){ 192 | if(table->last==entry) 193 | table->last= entry->pptr; 194 | if(entry->nptr) 195 | entry->nptr->pptr= entry->pptr; 196 | if(entry->pptr) 197 | entry->pptr->nptr= entry->nptr; 198 | next= entry->next; 199 | free(entry); 200 | return next; 201 | } 202 | entry->next= delete_fromilist(table,entry->next,key); 203 | return entry; 204 | } 205 | void table_idelete(HashTable*table,unsigned long key,node**address) 206 | 207 | /* void */ 208 | /* table_idelete(table,key) */ 209 | /* HashTable*table; */ 210 | /* unsigned long key; */ 211 | { 212 | unsigned long hkey; 213 | 214 | hkey= hash_ikey(key)%table->size; 215 | table->table[hkey]= delete_fromilist(table,table->table[hkey],key); 216 | table->elements--; 217 | } 218 | 219 | void 220 | table_idestroy(HashTable *table) 221 | { 222 | HashEntry*entry,*next; 223 | int i; 224 | 225 | for(i= 0;isize;i++){ 226 | entry= table->table[i]; 227 | while(entry){ 228 | next= entry->next; 229 | entry= next; 230 | } 231 | } 232 | free(table->table); 233 | } 234 | 235 | node*BookedAddress(rk,ord) 236 | int rk; 237 | long ord; 238 | { 239 | HashTable*p; 240 | node*address; 241 | 242 | #ifdef _DEBUG 243 | TRACING fprintf(logfile,"(%d) ROOT[%p] hash_table(%d) key:%ld(%p) ",rank,(void*)BookTable[rk],rk,ord,(void*)ord); 244 | #endif 245 | if(rk==rank){ 246 | #ifdef _DEBUG 247 | TRACING fprintf(logfile,"\n"); 248 | #endif 249 | return(node*)ord; 250 | } 251 | else 252 | { 253 | p= BookTable[rk]; 254 | if(table_iget(p,ord,&address)==0) { 255 | #ifdef _DEBUG 256 | TRACING fprintf(logfile,"it is not here\n"); 257 | #endif 258 | G.hot = CreateNewNode(G.hot); 259 | table_iput(p,ord,G.hot); 260 | G.hot->printed=!pflag; 261 | address = G.hot; 262 | }; 263 | #ifdef _DEBUG 264 | TRACING fprintf(logfile,"\n"); 265 | #endif 266 | return address; 267 | }; 268 | } 269 | 270 | node*StoreBookedAddress(rk,ord,sto) 271 | int rk; 272 | long ord; 273 | int sto; 274 | { 275 | HashTable*p; 276 | node*address; 277 | 278 | /* 279 | DEBUG{ 280 | fprintf(logfile,"(%d) ROOT[%p] hash_table(%d) key:%d(%p) ",rank,BookTable[rk],rk,ord,(node*)ord); 281 | fprintf(logfile," STO =%d",sto); 282 | }; 283 | */ 284 | 285 | if(rk==rank) 286 | { 287 | /* DEBUG fprintf(logfile,"\n");*/ 288 | return(node*)ord; 289 | } 290 | else 291 | { 292 | p= BookTable[rk]; 293 | if(table_iget(p,ord,&address)==0) 294 | { 295 | /* 296 | DEBUG fprintf(logfile,"it is not here\n"); 297 | */ 298 | if(sto==IN) 299 | { 300 | G.hot= CreateNewNode(G.hot); 301 | table_iput(p,ord,G.hot); 302 | G.hot->printed=!pflag; 303 | address= G.hot;} 304 | else 305 | { 306 | G.cold= CreateNewNode(G.cold); 307 | table_iput(p,ord,G.cold); 308 | G.cold->printed=!pflag; 309 | address= G.cold;} 310 | } 311 | else 312 | if (sto==OUT) {}; 313 | 314 | /* DEBUG fprintf(logfile,"\n");*/ 315 | return address; 316 | }; 317 | } 318 | -------------------------------------------------------------------------------- /graph.c: -------------------------------------------------------------------------------- 1 | /* Functions concerning the implementation of dynamic graphs 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | //#ifdef SOLARIS 27 | // #include 28 | //#endif 29 | #include 30 | #include 31 | //#include 32 | //#ifdef MPE_GRAPH 33 | //#include 34 | //#endif 35 | #include 36 | #include "var.h" 37 | 38 | /**/ 39 | 40 | graph*NewGraph() 41 | { 42 | graph*nS; 43 | nS= (graph*)calloc(1,sizeof(graph)); 44 | if(!nS) 45 | {fprintf(logfile,"graph allocation failure - ABORT");return 0;} 46 | return nS; 47 | } 48 | 49 | 50 | node*NewNode() 51 | { 52 | node*nS; 53 | 54 | nS= (node*)calloc(1,sizeof(node)); 55 | if(!nS) 56 | { 57 | printf("ALLOCATION FAILURE !!!!!!!!!\n\n"); 58 | fprintf(logfile,"node allocation failure - ABORT"); 59 | fflush(logfile); 60 | return 0;} 61 | return nS; 62 | } 63 | 64 | edge*NewReference() 65 | { 66 | edge*nS; 67 | 68 | nS= (edge*)calloc(1,sizeof(edge)); 69 | 70 | if(!nS) 71 | {fprintf(logfile,"edge allocation failure - ABORT");return 0;} 72 | return nS; 73 | } 74 | 75 | void LiberaV(P) 76 | edge*P; 77 | { 78 | struct messaggio m; 79 | 80 | if(P!=NULL) 81 | { 82 | /* 83 | #ifdef MEMDEBUG 84 | fprintf(logfile,"(%d) Free Memory Routine Entered\n",rank); 85 | fprintf(logfile,"(%d) Freeing Address [%p]\n",rank,P); 86 | fprintf(logfile,"(%d) Destination Node [%p]\n",rank,P->source); 87 | #endif 88 | */ 89 | if(P->vector!=NULL)LiberaV(P->vector); 90 | if(P->sign==PLUS) 91 | { 92 | StoreMessage(&m,P,P,(char*)"*",P->sto,P->side); 93 | m.tpy= EOT_TAG; 94 | PushMessage(&m); 95 | }; 96 | 97 | char *Xstr=NULL; 98 | int konst_index = 0; 99 | 100 | Xstr=strstr(P->weight,"X(2"); 101 | 102 | if (Xstr != NULL) 103 | { 104 | konst_index=atoi(&Xstr[4]); 105 | k[konst_index][2]--; 106 | } 107 | 108 | free(P); 109 | }; 110 | #ifdef _DEBUG 111 | DEBUG_MEM fprintf(logfile,"(%d) Exit Free Memory Procedure\n",rank); 112 | #endif 113 | 114 | return; 115 | } 116 | 117 | void AddEdge(S,rk,nS,sto,w,c,polarity,side) 118 | node*S; 119 | int rk; 120 | node*nS; 121 | int sto; 122 | term*w; 123 | int c; 124 | int polarity; 125 | int side; 126 | { 127 | edge*p; 128 | seminode*v; 129 | 130 | p= NewReference(); 131 | if(p==NULL) 132 | { 133 | /* 134 | DEBUG fprintf(logfile,"(%d) REFERENCE ALLOCATION FAILURE - ABORTING\n",rank); 135 | fflush(logfile); 136 | */ 137 | exit(-1); 138 | } 139 | else 140 | { 141 | strcpy(p->weight,w); 142 | if(polarity==LEFT) 143 | { 144 | v= &(S->left); 145 | } 146 | else v= &(S->right); 147 | 148 | p->vector = v->vector; 149 | p->rankpuit = rk; 150 | p->sto = sto; 151 | p->side = side; 152 | p->sign = PLUS; 153 | p->source = nS; 154 | p->creator = c; 155 | v->vector = p; 156 | if(v->length!=-1) v->length= (v->length)+1; 157 | 158 | #ifdef _DEBUG 159 | DEBUG_MEM { 160 | ShowEdge(p); 161 | fprintf(logfile,"(%d) LENNODE[%p]: %d\n",rank,(void*)S,v->length); 162 | fflush(logfile); 163 | }; 164 | #endif 165 | 166 | combusted= 0; 167 | return; 168 | }; 169 | } 170 | 171 | #ifdef NEWVERSION 172 | 173 | /* 174 | print details for the weight, specially for external symbols 175 | new representation for weights = words of handlers 176 | one handle is 177 | 1) bytecode = code for the action 178 | 2) exception handler = address for the symbol 179 | 3) code handler = address to the library code (obtained by the header) 180 | bytecode = [d,n,a,l] 181 | */ 182 | 183 | void ShowWeight(s) 184 | char *s; 185 | { 186 | switch ((int) s) 187 | { 188 | case P: ; break; 189 | case Q: ; break; 190 | case W: ; break; 191 | case X: ; break; 192 | } 193 | return ; 194 | } 195 | 196 | #endif 197 | 198 | void ShowEdge(e) 199 | edge *e; 200 | { 201 | fprintf(logfile,"(%d) target-hosting-process (%d), the has in/out flag %d\n",rank,e->rankpuit,e->sto); 202 | fprintf(logfile," creator (%d)\n", e->creator); 203 | 204 | fprintf(logfile," on side %d of the source (%ld)[%p]\n",e->side,(long)e->source,e->source); 205 | 206 | fprintf(logfile," weight |%s| and",e->weight) ; 207 | fprintf(logfile," status one-opt. sign %d\n",e->sign) ; 208 | fprintf(logfile," next edge on the same node [%p] \n",e->vector); 209 | fflush(logfile); 210 | } 211 | 212 | node*CreateNewNode(S) 213 | node*S; 214 | { 215 | node*nS; 216 | #ifdef _DEBUG 217 | DEBUG_MEM { 218 | fprintf(logfile,"IN routine creazione \n"); 219 | fflush(logfile); 220 | }; 221 | #endif 222 | 223 | nS= NewNode(); 224 | 225 | #ifdef _DEBUG 226 | DEBUG_MEM { 227 | fprintf(logfile,"(%d) Insert new node [%p] in S = [%p]\n",rank,nS,S); 228 | fflush(logfile); 229 | }; 230 | #endif 231 | 232 | 233 | nS->left.eot = 0; 234 | nS->left.weot = 1; 235 | nS->left.length = 0; 236 | nS->left.vector = NULL; 237 | nS->left.dejavu = NULL; 238 | 239 | nS->right.eot = 0; 240 | nS->right.weot = 1; 241 | nS->right.length = 0; 242 | nS->right.vector = NULL; 243 | nS->right.dejavu = NULL; 244 | 245 | nS->nextpuit = S; 246 | nS->families = 0; 247 | nS->prevpuit = NULL; 248 | if(S!=NULL)S->prevpuit= nS; 249 | temp++; 250 | #ifdef _DEBUG 251 | DEBUG_MEM { 252 | fprintf(logfile,"(%d) NEXT([%p])=[%p]\n",rank,nS,nS->nextpuit); 253 | fprintf(logfile,"(%d) PREV([%p])=[%p]\n",rank,nS,nS->prevpuit); 254 | if(S!=NULL) { 255 | fprintf(logfile,"(%d) NEXT([%p])=[%p]\n",rank,S,S->nextpuit); 256 | fprintf(logfile,"(%d) PREV([%p])=[%p]\n",rank,S,S->prevpuit); 257 | }; 258 | }; 259 | #endif 260 | return nS; 261 | } 262 | 263 | 264 | node*CreateNewBoundary(S) 265 | node*S; 266 | { 267 | node*nS; 268 | 269 | nS= NewNode(); 270 | nS->left.length= -1; 271 | nS->left.vector= NULL; 272 | nS->left.dejavu= NULL; 273 | nS->nextpuit= S; 274 | S->prevpuit= nS; 275 | return nS; 276 | } 277 | 278 | node*SinkRemove(P) 279 | node*P; 280 | { 281 | node*father_of_P= P->prevpuit; 282 | 283 | #ifdef _DEBUG 284 | DEBUG_MEM fprintf(logfile,"(%d) REMOVE NODE P=[%p]\n",rank,P); 285 | #endif 286 | fam_counter += P->families ; 287 | 288 | if((P->left.vector!=NULL)||(P->right.vector!=NULL)) 289 | { 290 | #ifdef _DEBUG 291 | DEBUG_MEM { 292 | fprintf(logfile,"(%d) Now I clean the ghost node 'cause",rank); 293 | fprintf(logfile," its combustion is completely exausted\n"); 294 | } 295 | #endif 296 | LiberaV(P->left.vector); 297 | LiberaV(P->right.vector); 298 | } 299 | else 300 | { 301 | /* 302 | DEBUG fprintf(logfile,"(%d) disconnected point checked\n",rank); 303 | */ 304 | }; 305 | if(G.hot==P) 306 | { 307 | G.hot= P->nextpuit; 308 | if(G.hot!=NULL)G.hot->prevpuit= NULL; 309 | #ifdef _DEBUG 310 | DEBUG_MEM { 311 | fprintf(logfile,"(%d) ok 1\n",rank); 312 | fprintf(logfile,"(%d) Graph HOT=[%p]\n",rank,G.hot); 313 | }; 314 | #endif 315 | } 316 | else 317 | { 318 | #ifdef _DEBUG 319 | DEBUG_MEM { 320 | father_of_P= P->prevpuit; 321 | fprintf(logfile,"(%d) ok 2\n",rank); 322 | fprintf(logfile,"(%d) NEXT(FATHER(P=[%p])=[%p])",rank,P,father_of_P); 323 | if(father_of_P!=NULL) 324 | fprintf(logfile,"= [%p]\n",father_of_P->nextpuit); 325 | else 326 | fprintf(logfile,"= NULL FATHER\n"); 327 | fflush(logfile); 328 | }; 329 | #endif 330 | P->prevpuit->nextpuit= P->nextpuit; 331 | if(P->nextpuit!=NULL)P->nextpuit->prevpuit= P->prevpuit; 332 | }; 333 | free(P); 334 | temp--; 335 | #ifdef _DEBUG 336 | DEBUG_MEM { 337 | fprintf(logfile,"REMOVED NODE\n"); 338 | fprintf(logfile,"(%d) ok 3\n",rank); 339 | fprintf(logfile,"(%d) ok 4 [%p]\n",rank,father_of_P); 340 | fflush(logfile); 341 | } 342 | #endif 343 | return father_of_P; 344 | } 345 | 346 | edge*EdgeRemove(e,P) 347 | edge*e; 348 | node*P; 349 | { 350 | edge*p,*pp; 351 | 352 | if(P->left.vector==NULL){return 0;} 353 | else 354 | { 355 | pp= NULL; 356 | p= P->left.vector; 357 | for(;((p!=e)&&(p!=NULL));) 358 | { 359 | pp= p; 360 | p= p->vector; 361 | }; 362 | if((p!=NULL)&&(pp!=NULL)) 363 | { 364 | pp->vector= p->vector; 365 | pp= P->left.vector;} 366 | else 367 | if((p!=NULL)&&(pp==NULL)) 368 | {pp= p->vector;} 369 | else 370 | {fprintf(logfile,"ERROR!\n ");return 0;}; 371 | 372 | free(e); 373 | P->left.length= P->left.length-1; 374 | return pp; 375 | 376 | }; 377 | } 378 | 379 | 380 | -------------------------------------------------------------------------------- /h/buildgraph.h: -------------------------------------------------------------------------------- 1 | /* Syntax interpretation function used in the parser 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef bgraph_h 21 | #define bgraph_h 22 | 23 | 24 | #include 25 | 26 | typedef struct termGraph { 27 | char nameTerm[160000]; 28 | struct node *root; 29 | struct table *listOfVar; 30 | } termGraph; 31 | 32 | typedef struct table { 33 | char *name; 34 | struct node *ptrNode; 35 | struct table *next; 36 | } table; 37 | 38 | typedef struct symTbl { 39 | char *symName; 40 | struct termGraph *symTerm; 41 | struct symTbl *next; 42 | } symTbl; 43 | 44 | void InitializeIncoming(termGraph*t); 45 | 46 | termGraph *BuildVar(char*); 47 | termGraph *BuildLambda(char*,termGraph*); 48 | termGraph *BuildApplication(termGraph*,termGraph*); 49 | termGraph *BuildBool(char*); 50 | termGraph *BuildNumber(char*); 51 | termGraph *BuildF1Arg(char *namef, termGraph *arg); 52 | termGraph *BuildF2Arg(char *namef, termGraph *arg1, termGraph *arg2); 53 | termGraph *BuildXF1Arg(char *namef, termGraph *arg); 54 | termGraph *BuildXF2Arg(char *namef, termGraph *arg1, termGraph *arg2); 55 | termGraph *BuildITE(termGraph *arg1, termGraph *arg2, termGraph *arg3); 56 | termGraph *BuildLet(char *arg1, termGraph *arg2, termGraph *arg3); 57 | termGraph *BuildRec(char *x, termGraph *M); 58 | /* ANTO */ 59 | void CallXF1ArgChar(char *, char *); 60 | void CallXF1ArgUser(char *, char *); 61 | int AddEntryInk(int,USERTYPE); 62 | void SetNextKIndex(void); 63 | /* ANTO */ 64 | int AddEntryInf(char*); 65 | int XAddEntryInf(char*,int); 66 | int XAddFun(int, USERTYPE); 67 | 68 | edge *AddAnEdge(edge*,char*,node *,int); 69 | void Lift(termGraph*t); 70 | void LiftEdges(edge *e); 71 | void P_Q(node *,char*); 72 | void FreeNode(node*n); 73 | termGraph *MergeNodes(termGraph *newTerm, termGraph *t1, termGraph *t2); 74 | void MeltNodes(node *,node *); 75 | termGraph *Duplicate(termGraph*); 76 | void Weightcpy(char newW[],char oldW[]); 77 | node *CopyNode(node*); 78 | table *RemoveFromList(table*,char*); 79 | 80 | void PutSymbol(char *symbol, termGraph *t); 81 | void DeallocTermGraph(termGraph *t); 82 | termGraph *IsThere(char*); 83 | void ShowTable(); 84 | 85 | void MostraNodo(node *n); 86 | void MostraArchi(edge*e); 87 | void MostraListaDiNodi(node *n); 88 | void MostraGrafo(termGraph *t); 89 | void MostraTabelle(); 90 | /* ANTO */ 91 | void LoadLib(char *path); 92 | void BCastLoad(void); 93 | void CloseLib(void); 94 | 95 | 96 | 97 | USERTYPE pelcr_not(USERTYPE); 98 | USERTYPE pelcr_pred(USERTYPE); 99 | USERTYPE pelcr_succ(USERTYPE); 100 | USERTYPE pelcr_iszero(USERTYPE); 101 | USERTYPE pelcr_add(USERTYPE, USERTYPE); 102 | USERTYPE pelcr_and(USERTYPE,USERTYPE); 103 | USERTYPE pelcr_mult(USERTYPE, USERTYPE); 104 | USERTYPE pelcr_great(USERTYPE,USERTYPE); 105 | /* ANTO */ 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /h/combustion.h: -------------------------------------------------------------------------------- 1 | /* Header for the processor of the workload 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | 21 | #ifndef combustion_h 22 | #define combustion_h 23 | 24 | /*#define MAXPENDING 320000*/ 25 | 26 | /*#define MAXPENDING 920000*/ 27 | 28 | #define MAXPENDING 520000 29 | 30 | struct messaggio{ 31 | /* debugging */ 32 | long timestamp; /* debugging information to check non-overlapping of messages */ 33 | int temp; /* piggybacking of the workload of the hosting process */ 34 | 35 | /* symbolic and graph information */ 36 | int tpy; /* the type EOT or ADD_TAG */ 37 | int sender; /* the process sending this message */ 38 | int side; /* the side of the edge on the target */ 39 | edge vsource; /* the structure storing the "source" of the edge carried by the message*/ 40 | edge vtarget; /* the structure storing the "target" of the edge carried by the message*/ 41 | char weight[MAXLENWEIGHT]; /* weight string */ 42 | 43 | /* side effects */ 44 | int funWhich; /* this message carries a functional symbol: this is symbol table entry */ 45 | USERTYPE funWait; /* the function is in the stack with a certain number of arguments */ 46 | /* ANTO 47 | Attenzione !!! Modificato temporaneamente per abilitare il 48 | passaggio di costanti long long. 49 | Va definita una migliore stategia per il trasferimento delle 50 | costanti, magari utilizzando funArgs... 51 | ANTO */ 52 | int funNarg; /* this is the arity of the functional symbol */ 53 | int funType; /* this is a pointer to the function (output) type */ 54 | /* ANTO */ 55 | USERTYPE funArgs[MAXNUMARG]; /* ??? Carlo che hai fatto, a che serve questo ? */ 56 | /* ANTO */ 57 | }; 58 | 59 | struct mbuffer{ 60 | int first; 61 | int last; 62 | struct messaggio stack[MAXPENDING+1]; 63 | }; 64 | 65 | struct termination_msg{ 66 | int sender; 67 | int OutCounter[MAXNPROCESS]; 68 | int InCounter[MAXNPROCESS]; 69 | }; 70 | 71 | void ComputeResult(); 72 | void PrintResult(); 73 | 74 | int BdumpS(struct mbuffer*); 75 | int BDump(struct mbuffer*); 76 | 77 | void NodeCombustion(node*n,int polarity); 78 | void StoreMessage(struct messaggio*m,edge*t,edge*s,char*w,int sto,int p); 79 | void ShowMessage(struct messaggio*m); 80 | 81 | int UpperBound(struct messaggio*m); 82 | edge*InitReference(edge*aux); 83 | 84 | void FunReceiveMessages(); 85 | void FunInteraction(); 86 | 87 | void WriteStats(); 88 | void PushIncomingMessage(int priority, struct messaggio *m); 89 | int EmptyBuffer(struct mbuffer*l); 90 | 91 | void Finally(); 92 | #endif 93 | -------------------------------------------------------------------------------- /h/distribution.h: -------------------------------------------------------------------------------- 1 | 2 | /* Header for the Manager for distribution of workload 3 | 4 | Copyright (C) 1997-2015 Marco Pedicini 5 | 6 | This file is part of PELCR. 7 | 8 | PELCR is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | PELCR is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with PELCR. If not, see . */ 20 | 21 | #ifndef distribution_h 22 | #define distribution_h 23 | 24 | void InitTable();/**/ 25 | 26 | void buf_flush();/**/ 27 | 28 | void SendAddEdge(edge*N,edge*E,char*sw,int sto);/**/ 29 | int SendLightProcess(void);/**/ 30 | int LightProcess(int dest);/**/ 31 | int LightProcess2(int dest);/**/ 32 | int LightProcess3(int dest);/**/ 33 | int LightProcess5(int dest);/**/ 34 | int LightProcess6(int dest);/**/ 35 | int LightProcess7(int dest);/**/ 36 | int LightProcess8(int dest);/**/ 37 | 38 | void SendCreateNewNode(int dest,int sto,edge*nS);/**/ 39 | int NouvelleReservation(int dest);/**/ 40 | void PopMessage(struct messaggio *m,struct mbuffer *l); 41 | void PushMessage(struct messaggio *m); 42 | 43 | void AggregationControl1(); 44 | void AggregationControl2(); 45 | void AggregationControl3(); 46 | void AggregationControl4(); 47 | void AggregationControl5(); 48 | 49 | void *ThreadReceiveMsgs(); 50 | void *ThreadInteraction(); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /h/dvm.h: -------------------------------------------------------------------------------- 1 | /* Manager of global address space of memory for graph distributed allocation 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef vm_h 21 | #define vm_h 22 | 23 | 24 | typedef struct HashEntry 25 | { 26 | struct HashEntry*nptr,*pptr; 27 | unsigned long key; 28 | node*address; 29 | struct HashEntry*next; 30 | }HashEntry; 31 | 32 | typedef struct HashTable{ 33 | int elements; 34 | int size; 35 | HashEntry**table; 36 | HashEntry*last; 37 | }HashTable; 38 | 39 | HashTable*table_init(HashTable*table); 40 | 41 | unsigned long hash_ikey(unsigned long key); 42 | void rebuild_itable(HashTable*table); 43 | HashEntry*delete_fromilist(HashTable*table,HashEntry*entry,unsigned long key); 44 | 45 | void table_iput(HashTable*table,unsigned long key,node*address); 46 | int table_iget (HashTable*table,unsigned long key,node**address); 47 | 48 | void table_idelete(HashTable*table,unsigned long key,node**address); 49 | void table_idestroy(HashTable*table); 50 | node*BookedAddress(int rk,long ord); 51 | node*StoreBookedAddress(int rk,long ord,int sto); 52 | void*safemalloc(int length); 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /h/gml_parser.h: -------------------------------------------------------------------------------- 1 | /* Parser of graphs in GML format 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef gml_parser_h 21 | #define gml_parser_h 22 | 23 | #include "mydefs.h" 24 | #include "var.h" 25 | #include "symbolic.h" 26 | #include "graph.h" 27 | #include "combustion.h" 28 | #include "gml_scanner.h" 29 | 30 | union GML_pair_val { 31 | long integer; 32 | double floating; 33 | char* string; 34 | struct GML_pair* list; 35 | }; 36 | 37 | struct GML_pair { 38 | char* key; 39 | GML_value kind; 40 | union GML_pair_val value; 41 | struct GML_pair* next; 42 | }; 43 | 44 | struct GML_list_elem { 45 | char* key; 46 | struct GML_list_elem* next; 47 | }; 48 | 49 | struct GML_stat { 50 | struct GML_error err; 51 | struct GML_list_elem* key_list; 52 | }; 53 | 54 | /* 55 | * returns list of KEY - VALUE pairs. Errors and a pointer to a list 56 | * of key-names are returned in GML_stat 57 | */ 58 | 59 | struct GML_pair* GML_parser (FILE*, struct GML_stat*, int); 60 | 61 | /* 62 | * free memory used in a list of GML_pair 63 | */ 64 | 65 | void GML_free_list (struct GML_pair*, struct GML_list_elem*); 66 | 67 | 68 | /* 69 | * debugging 70 | */ 71 | 72 | void GML_print_list (struct GML_pair*, int); 73 | 74 | int GML_edge_det(struct GML_pair*list, struct messaggio*pozzi, int npozzi); 75 | 76 | //int SinkList(struct messaggio *,struct messaggio *,int); 77 | 78 | #endif 79 | 80 | 81 | -------------------------------------------------------------------------------- /h/gml_scanner.h: -------------------------------------------------------------------------------- 1 | /* Scanner of graphs in GML format 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef gml_scanner_h 21 | #define gml_scanner_h 22 | 23 | #include 24 | 25 | /* 26 | * start-size of buffers for reading strings. If too small it will be enlarged 27 | * dynamically 28 | */ 29 | 30 | #define INITIAL_SIZE 1024 31 | 32 | typedef enum { 33 | GML_KEY, GML_INT, GML_DOUBLE, GML_STRING, GML_L_BRACKET, 34 | GML_R_BRACKET, GML_END, GML_LIST, GML_ERROR 35 | } GML_value; 36 | 37 | 38 | typedef enum { 39 | GML_UNEXPECTED, GML_SYNTAX, GML_PREMATURE_EOF, GML_TOO_MANY_DIGITS, 40 | GML_OPEN_BRACKET, GML_TOO_MANY_BRACKETS, GML_OK 41 | } GML_error_value; 42 | 43 | 44 | struct GML_error { 45 | GML_error_value err_num; 46 | int line; 47 | int column; 48 | }; 49 | 50 | 51 | union GML_tok_val { 52 | long integer; 53 | double floating; 54 | char* string; 55 | struct GML_error err; 56 | }; 57 | 58 | 59 | struct GML_token { 60 | GML_value kind; 61 | union GML_tok_val value; 62 | }; 63 | 64 | /* 65 | * global variables 66 | */ 67 | 68 | extern unsigned int GML_line; 69 | extern unsigned int GML_column; 70 | 71 | /* 72 | * if you are interested in the position where an error occured it is a good 73 | * idea to set GML_line and GML_column back. 74 | * This is what GML_init does. 75 | */ 76 | 77 | void GML_init (); 78 | 79 | /* 80 | * returns the next token in file. If an error occured it will be stored in 81 | * GML_token. 82 | */ 83 | 84 | struct GML_token GML_scanner (FILE*); 85 | 86 | #endif 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /h/graph.h: -------------------------------------------------------------------------------- 1 | /* Functions concerning the implementation of dynamic graphs 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef graph_h 21 | #define graph_h 22 | 23 | typedef struct seminode { 24 | int eot; /* numero di eot ricevuto */ 25 | int length; 26 | int weot; /* numero di eot attesi */ 27 | struct edge*vector; 28 | struct edge*dejavu; 29 | } seminode; 30 | 31 | 32 | typedef struct node { 33 | long pro; 34 | seminode left; 35 | seminode right; 36 | int mu_local; /* misura di localita' del nodo = n. archi con sorgente locale*/ 37 | int mu_remote; /* n. archi con sorgente remota */ 38 | struct node*nextpuit; 39 | struct node*prevpuit; 40 | int printed; /* used in Print function to avoid duplication of the node*/ 41 | int families ; /* the maximal number of family reductions in compositions of edges onto the node*/ 42 | } node; 43 | 44 | typedef struct edge { 45 | struct edge*vector; 46 | node*source; 47 | int sto; 48 | int sign; 49 | int side; 50 | int rankpuit; 51 | int creator; 52 | char weight[MAXLENWEIGHT]; 53 | } edge; 54 | 55 | typedef struct graph { 56 | node*hot; 57 | node*cold; 58 | 59 | node*border; 60 | } graph; 61 | 62 | graph*NewGraph(void); 63 | node*NewNode(void); 64 | edge*NewReference(void); 65 | void LiberaV(edge*P); 66 | void AddEdge(node*S,int rk,node*nS,int sto,term*w,int c,int polarity,int side); 67 | node*CreateNewNode(node*S); 68 | node*CreateNewBoundary(node*S); 69 | node*SinkRemove(node*P); 70 | edge*EdgeRemove(edge*e,node*P); 71 | void ShowEdge(edge*); 72 | void ShowWeight(char *s); 73 | #endif 74 | -------------------------------------------------------------------------------- /h/io.h: -------------------------------------------------------------------------------- 1 | /* Header for Input and output functions: graph dumping, readback, graph reader 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #ifndef io_h 21 | #define io_h 22 | 23 | void OpenFileInitStruct();/**/ 24 | 25 | void Print(graph g,struct mbuffer *b, long int sq); 26 | int SinkList( 27 | struct messaggio*m, 28 | struct messaggio*l, 29 | int length); 30 | void read_back( node*); 31 | void SetOutputFile(char *name); 32 | void SetDirectory(char *name) ; 33 | void WriteStatus(void); 34 | void WriteHelp(void); 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /h/lambdastar.h: -------------------------------------------------------------------------------- 1 | /* Data structures required to manage external functions and C-native data types 2 | Copyright (C) 1997-2015 Marco Pedicini 3 | 4 | This file is part of PELCR. 5 | 6 | PELCR is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | PELCR is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with PELCR. If not, see . */ 18 | 19 | 20 | #ifndef LAMBDASTAR_H 21 | #define LAMBDASTAR_H 22 | 23 | 24 | 25 | #define TYPE 1 26 | #define KONST 2 27 | #define FUNC 3 28 | #define SYNC 4 29 | #define ARG 5 30 | #define ITE 6 31 | #define ARGLAST 7 32 | 33 | #define BOOL 1 34 | #define NAT 2 35 | 36 | #define TIN 0 37 | #define TOUT 1 38 | 39 | /* ANTO */ 40 | #define EXT 0 41 | /* ANTO */ 42 | #define SUCC 1 43 | #define ADD 2 44 | #define PRED 3 45 | #define MULT 4 46 | #define AND 5 47 | #define NOT 6 48 | #define ISZERO 7 49 | #define OR 8 50 | #define GREATER 9 51 | 52 | 53 | #define MAXNUMCOST 10000 /*era 1000000*/ 54 | #define MAXTYPE 20 /*era 10*/ 55 | #define MAXFUNCTIONS 50 /*era 50*/ 56 | #define MAXDATAVARS 20 /*era 10*/ 57 | 58 | typedef struct functionstack 59 | { 60 | int which; 61 | int type; 62 | int narg; 63 | long wait; 64 | USERTYPE (*fun)(); 65 | USERTYPE s[MAXNUMARG]; 66 | /* ANTO */ 67 | char name[MAXNAMELEN]; 68 | int fun_id; 69 | /* ANTO */ 70 | } functionstack ; 71 | 72 | /* ANTO */ 73 | USERTYPE k[MAXNUMCOST][3]; 74 | /* ANTO */ 75 | 76 | functionstack f[MAXFUNCTIONS]; 77 | functionstack f_db[MAXFUNCTIONS]; 78 | int t[5][2]; 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /h/mydefs.h: -------------------------------------------------------------------------------- 1 | /* Variables and struct definitions 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | 21 | #ifndef mydefs_h 22 | #define mydefs_h 23 | 24 | #define NODEBUG if (OFF) 25 | 26 | #ifdef _DEBUG 27 | #define DEBUG if (TRACE) 28 | #define DEBUG_EOT DEBUG 29 | #define DEBUG_PRINT DEBUG 30 | #define DEBUG_MEM DEBUG 31 | #define DEBUG_IO DEBUG 32 | #define DEBUG_LAMBDA DEBUG 33 | #define DEBUG_PARSER DEBUG 34 | #define DEBUG_WEIGHT DEBUG 35 | #define DEBUG_AGGREGATION DEBUG 36 | #define DEBUG_DISTRIBUTION DEBUG 37 | #define DEBUG_XFUNC DEBUG 38 | #define DEBUG_XDATA DEBUG 39 | #define DEBUG_HASH DEBUG 40 | #else 41 | #define DEBUG_EOT OFF 42 | #endif 43 | 44 | #define OUTPUT if (PRINT) 45 | #define OUTPUT2 if (PRINT2) 46 | #define OUTPUTFILE if ((outflag==1)) 47 | 48 | #define TRACE traceflag 49 | #define PRINT ON 50 | #define PRINT2 verflag 51 | #define TRACING if (TRACE) 52 | 53 | #define ON 1 54 | #define OFF 0 55 | 56 | #define THREAD OFF 57 | 58 | #define TRUE 1 59 | #define FALSE 0 60 | 61 | /*nodo IN: appartiene alla forma normale; nodo OUT:non appartiene alla forma normale.......o viceversa?*/ 62 | #define IN 1 63 | #define OUT 0 64 | 65 | #define STICKY 2 66 | #define PLUS 1 67 | #define MINUS 0 68 | 69 | /*seminodo*/ 70 | #define LEFT 1 71 | #define RIGHT 0 72 | 73 | #define MAXLENWEIGHT 100 74 | #define MAXNPROCESS 1000 75 | #define MAXNUMARG 2 76 | /* ANTO */ 77 | #define MAXNAMELEN 1000 78 | /* ANTO */ 79 | 80 | 81 | #define WARMING (rank>0) 82 | #define INITIALIZER (rank==0) 83 | 84 | 85 | #define STORAGEPROCESS 0 86 | #define MANAGERPROCESS 0 87 | #define INITIALIZERPROCESS 0 88 | 89 | #define ADD_REV_TAG 0 90 | #define ADD_TAG 1 91 | #define CREATE_TAG 2 92 | #define EOT_TAG 3 93 | #define DIE_TAG 4 94 | #define COMMAND_TAG 5 95 | #define DATA_TAG 6 96 | #define ASK_TAG 7 97 | #define PROCESS_TAG 8 98 | #define START_TAG 9 99 | /* ANTO */ 100 | #define LOADLIB_TAG 10 101 | #define LOADFUN_TAG 11 102 | /* ANTO */ 103 | 104 | 105 | 106 | /* passi per forzare la send */ 107 | /* #define CHECKTICKS 1000 8PE */ 108 | 109 | #define CHECKTICKS 1000 110 | 111 | #define BURST 10 112 | 113 | 114 | /* #define MAXTICKS 100*/ 115 | 116 | #define LENBUF 20000 117 | 118 | /***********************************************************************/ 119 | /* FREQUENZA di STAMPA delle STATISTICHE (misurata in numero di loop) */ 120 | /***********************************************************************/ 121 | 122 | #define FREQ 150 123 | 124 | /*******************************************88***************************/ 125 | /* PARAMETRI di SOGLIA */ 126 | /* (a che percentuale si deve trovare il buffer per far scattare */ 127 | /* una modifica dei parametri di aggregazione) */ 128 | /************************************************************************/ 129 | 130 | 131 | #define TRHLEFT 0.80 132 | #define TRHRIGHT 0.80 133 | 134 | /****************************************************************************** 135 | Parametri per l'aggregazione dinamica variando la dimensione del buffer 136 | *******************************************************************************/ 137 | 138 | /* risoluzione temporale per la valutazione della politica di aggregazione */ 139 | /* ovvero ogni quanto fare il controllo sulla aggregationWindow */ 140 | #define OBSERVATIONWINDOW 200 141 | 142 | /* valore iniziale della dimensione della finestra di aggregazione */ 143 | #define AGGREGATIONWINDOW 45 144 | 145 | /* MIN e, sotto, MAX della aggregationWindow */ 146 | #define MAXAWIN 200 147 | #define MINAWIN 20 148 | 149 | 150 | /*di quanto diminuisco la dim dell'aggregatioWindow*/ 151 | /*di quanto aumento la dim dell'aggregatioWindow*/ 152 | #define ALPHA -2.0 153 | #define BETA 2.0 154 | 155 | /* 156 | tenere conto della dimensione del buffer di MPI nella scelta 157 | della dimensione massima del messaggio fisico a inviare 158 | */ 159 | 160 | /***************************************************************************/ 161 | /* Parametri per l'aggregazione dinamica variando il maxtick */ 162 | /***************************************************************************/ 163 | /* il timeout per il buffer contenente i messaggi da aggregare destinati al processo (pr)*/ 164 | /* e' mantenuto nell'array maxTick[pr] */ 165 | 166 | 167 | /* Buffer TIMEOUT iniziale (maxtick di partenza) */ 168 | #define TICK 60 169 | #define TICK_MOVE 1 170 | 171 | 172 | /* RANGE per la variazione del Buffer TIMEOUT (maxtick massimo e minimo) */ 173 | #define MAXTICK 500 174 | #define MINTICK 5 175 | 176 | 177 | /* incrementi per il maxtick */ 178 | #define ALPHATICK 10.0 179 | #define BETATICK -10.0 180 | 181 | 182 | 183 | /* code di priorita' incoming 6/10/2001 */ 184 | /* 185 | min priority is associated to EOT in order to guarantee that 186 | an edge cannot arrive to its target node after that node has been 187 | removed. 188 | */ 189 | #define MAXPRIORITY 0 190 | #define MINPRIORITY 1 191 | 192 | 193 | /* numbero of cut nodes in a parsed term */ 194 | #define MAXCUTNODES 100 195 | #endif 196 | -------------------------------------------------------------------------------- /h/parser.tab.h: -------------------------------------------------------------------------------- 1 | /* A Bison parser, made by GNU Bison 2.3. */ 2 | 3 | /* Skeleton interface for Bison's Yacc-like parsers in C 4 | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 | Free Software Foundation, Inc. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2, or (at your option) 11 | any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 | Boston, MA 02110-1301, USA. */ 22 | 23 | /* As a special exception, you may create a larger work that contains 24 | part or all of the Bison parser skeleton and distribute that work 25 | under terms of your choice, so long as that work isn't itself a 26 | parser generator using the skeleton or a modified version thereof 27 | as a parser skeleton. Alternatively, if you modify or redistribute 28 | the parser skeleton itself, you may (at your option) remove this 29 | special exception, which will cause the skeleton and the resulting 30 | Bison output files to be licensed under the GNU General Public 31 | License without this special exception. 32 | 33 | This special exception was added by the Free Software Foundation in 34 | version 2.2 of Bison. */ 35 | 36 | /* Tokens. */ 37 | #ifndef YYTOKENTYPE 38 | # define YYTOKENTYPE 39 | /* Put the tokens into the symbol table, so that GDB and other debuggers 40 | know about them. */ 41 | enum yytokentype { 42 | HELP = 258, 43 | TRACEF = 259, 44 | VERBOSEF = 260, 45 | USELIB = 261, 46 | QUIT = 262, 47 | WRITE = 263, 48 | SETDIR = 264, 49 | SETLOOPS = 265, 50 | SETFIRES = 266, 51 | STATUS = 267, 52 | SYMBOL = 268, 53 | REC = 269, 54 | DEF = 270, 55 | IF = 271, 56 | THEN = 272, 57 | ELSE = 273, 58 | GMLGRAPH = 274, 59 | NL = 275, 60 | EQ = 276, 61 | LAMBDA = 277, 62 | OP1 = 278, 63 | OP2 = 279, 64 | ID = 280, 65 | LOP1 = 281, 66 | LOP2 = 282, 67 | NUM = 283, 68 | BOOLEAN = 284, 69 | F1ARG = 285, 70 | F2ARG = 286, 71 | XFUNCTION = 287, 72 | LET = 288, 73 | INN = 289, 74 | PATH = 290, 75 | XCALL = 291 76 | }; 77 | #endif 78 | /* Tokens. */ 79 | #define HELP 258 80 | #define TRACEF 259 81 | #define VERBOSEF 260 82 | #define USELIB 261 83 | #define QUIT 262 84 | #define WRITE 263 85 | #define SETDIR 264 86 | #define SETLOOPS 265 87 | #define SETFIRES 266 88 | #define STATUS 267 89 | #define SYMBOL 268 90 | #define REC 269 91 | #define DEF 270 92 | #define IF 271 93 | #define THEN 272 94 | #define ELSE 273 95 | #define GMLGRAPH 274 96 | #define NL 275 97 | #define EQ 276 98 | #define LAMBDA 277 99 | #define OP1 278 100 | #define OP2 279 101 | #define ID 280 102 | #define LOP1 281 103 | #define LOP2 282 104 | #define NUM 283 105 | #define BOOLEAN 284 106 | #define F1ARG 285 107 | #define F2ARG 286 108 | #define XFUNCTION 287 109 | #define LET 288 110 | #define INN 289 111 | #define PATH 290 112 | #define XCALL 291 113 | 114 | 115 | 116 | 117 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 118 | typedef union YYSTYPE 119 | #line 59 "PELCR/parser.y" 120 | { 121 | char string[500]; 122 | int number; 123 | int intero; 124 | struct termGraph *grafo; 125 | } 126 | /* Line 1529 of yacc.c. */ 127 | #line 128 "parser.tab.h" 128 | YYSTYPE; 129 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 130 | # define YYSTYPE_IS_DECLARED 1 131 | # define YYSTYPE_IS_TRIVIAL 1 132 | #endif 133 | 134 | extern YYSTYPE yylval; 135 | 136 | -------------------------------------------------------------------------------- /h/symbolic.h: -------------------------------------------------------------------------------- 1 | /* Header for the implementation of Girard's dynamic algebra 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | 21 | #ifndef symbolic_h 22 | #define symbolic_h 23 | 24 | typedef char term; 25 | 26 | 27 | /* extern int k[MAXNUMCOST][2]; */ 28 | /* extern functionstack f[MAXFUNCTIONS]; */ 29 | /* extern int t[5][2]; */ 30 | 31 | extern int kindex; 32 | extern int newval; 33 | extern int findex; 34 | extern int fcounter; 35 | 36 | /* extern double (*funcs[MAXFUNCTIONS])(double); */ 37 | /* extern void *vars[MAXDATAVARS]; */ 38 | 39 | void checkone(char*s); 40 | int findType(int tipo); 41 | int product(char*a,char*b,char*a1,char*b1); 42 | int isone(char*a); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /h/var.h: -------------------------------------------------------------------------------- 1 | /* Constants and 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "mydefs.h" 27 | #include "symbolic.h" 28 | #include "graph.h" 29 | #include "combustion.h" 30 | //#include "y.tab.h" 31 | #include "io.h" 32 | #include "dvm.h" 33 | #include "distribution.h" 34 | #include "lambdastar.h" 35 | #include "buildgraph.h" 36 | 37 | /* HashTable*BookTable[MAXNPROCESS]; */ 38 | #ifndef var_h 39 | #define var_h 40 | /* ANTO */ 41 | /* pointer to xfunction from dynamically loaded library */ 42 | void *handle; 43 | /* path of dynamically loaded library */ 44 | char Path[MAXNAMELEN]; 45 | const char *error; 46 | /* ANTO */ 47 | 48 | long maxloop,maxfires,maxbips; 49 | 50 | long timestamp,outtimestamp; 51 | long aggregation_cumulate, num_receives; 52 | 53 | long global_physical_msgs; 54 | 55 | int lightprocess ; 56 | int schedule ; 57 | int pflag ; 58 | 59 | int traceflag, inflag, outflag,verflag; 60 | long maxloo,maxfir,bip,bip2,bip3,bip4,fam_counter; 61 | int locf_counter; 62 | long fires,loops,prnsteps,ones; 63 | int unaddtest,uneottest; 64 | int laddtest,leottest; 65 | long idle,lidle,lbip2; 66 | int temp,nhot,ncold,scount; 67 | long francesco,lastloop; 68 | 69 | int npozzi; 70 | 71 | int fra_hot; 72 | 73 | struct tms smtime; 74 | 75 | FILE*readfile,*writefile,*firfile,*tempfile,*coldfile,*anamfile; 76 | FILE*mawfile[MAXNPROCESS],*maxwinfile[MAXNPROCESS]; 77 | FILE*trivfile,*hotfile,*nofile,*logfile; 78 | char infile[MAXNAMELEN],outfile[MAXNAMELEN],directoryname[MAXNAMELEN]; 79 | char rline[MAXLENWEIGHT]; 80 | node*environment; 81 | 82 | int comm,rank,size,ierr; 83 | int TempProcess[MAXNPROCESS],TableProcess[MAXNPROCESS],number_of_processes; 84 | int OutCounter[MAXNPROCESS],InCounter[MAXNPROCESS]; 85 | int combusted; 86 | int ending,end_computation,check_passed; 87 | 88 | MPI_Status status; 89 | MPI_Request data_request,add_request,create_request,eot_request,die_request,request; 90 | MPI_Request send_add_request,send_eot_request[MAXNPROCESS],send_die_request; 91 | 92 | int dataflag,saddflag,addflag,createflag,eotflag,dieflag,flag,h; 93 | int sebuf[MAXLENWEIGHT]; 94 | int sbuf[MAXLENWEIGHT]; 95 | long sbuflong[10]; 96 | //int reotbuf[10],raddbuf[MAXLENWEIGHT+7*sizeof(long)],rcreatebuf[10],rdiebuf[10]; 97 | int reotbuf[10],raddbuf[MAXLENWEIGHT],rcreatebuf[10],rdiebuf[10]; 98 | 99 | /*struct mbuffer incoming;*/ 100 | struct mbuffer incoming[MINPRIORITY]; /* array of buffers of incoming messages */ 101 | int maxubound; 102 | int local_pending; 103 | int edges_counter; 104 | 105 | /*outgoing,*outbuffer= &outgoing;*/ 106 | 107 | int newval; 108 | 109 | /********** Carlo *******************************************/ 110 | char buf[MAXNPROCESS][sizeof(long) + (1+MAXAWIN)*sizeof(struct messaggio)]; 111 | char rbuf[sizeof(int) + (1+MAXAWIN)*sizeof(struct messaggio)]; 112 | char sendbuffer[150*(sizeof(int) + (1+MAXAWIN)*sizeof(struct messaggio))]; 113 | 114 | /************************************************************/ 115 | 116 | int OutTerminationStatus[MAXNPROCESS][MAXNPROCESS]; 117 | int InTerminationStatus[MAXNPROCESS][MAXNPROCESS]; 118 | int outcontrol[MAXNPROCESS]; 119 | int tickcontrol[MAXNPROCESS]; 120 | struct messaggio msg; 121 | 122 | float last_rate[MAXNPROCESS]; 123 | float current_rate; 124 | 125 | graph G; 126 | 127 | /******************* Carlo ***********************************/ 128 | 129 | int nrFisicMsg[MAXNPROCESS]; 130 | int nrApplMsg[MAXNPROCESS]; 131 | float aggregationRatio[MAXNPROCESS]; 132 | 133 | int aggregationWindow[MAXNPROCESS]; 134 | int maxTick[MAXNPROCESS]; 135 | 136 | time_t oss1, oss2;/* ,t;*/ 137 | long nTickSend; /* Quante volte spedisco allo scadere del tick */ 138 | long nFullSend; /* Quante volte spedisco perche il messaggio fisico e' pieno */ 139 | 140 | 141 | time_t inittime,finaltime,tim; 142 | 143 | /****************************************************/ 144 | /* per i thread */ 145 | 146 | pthread_mutex_t mutex; 147 | 148 | /****************************************************/ 149 | 150 | 151 | /********************************* Marco 06032001 ***********************/ 152 | 153 | /**** integro l'ampiezza della finestra di timeout **********************/ 154 | long cumulate_timeout[MAXNPROCESS]; 155 | long physical_msgs[MAXNPROCESS]; 156 | long applicative_msgs[MAXNPROCESS]; 157 | /***********************************************************************/ 158 | 159 | /* per lo scheduler */ 160 | int contatore_combustioni_f; 161 | 162 | HashTable*BookTable[MAXNPROCESS]; 163 | 164 | 165 | struct messaggio pozzi[MAXCUTNODES]; /*maximal number of cut-nodes in the parsed input*/ 166 | 167 | int lift; 168 | int varname; 169 | symTbl *symbolTable; 170 | 171 | int kindex; 172 | int findex; 173 | int fcounter; 174 | 175 | node*principal ; 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /io.c: -------------------------------------------------------------------------------- 1 | /* Input and output functions: graph dumping, readback, graph reader 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "h/gml_parser.h" 26 | 27 | #ifdef SOLARIS 28 | #include 29 | #endif 30 | #include 31 | #include 32 | 33 | #ifdef MPE_GRAPH 34 | #include 35 | #endif 36 | #include 37 | #include 38 | #include 39 | #include "var.h" 40 | 41 | unsigned int GML_line; 42 | unsigned int GML_column; 43 | 44 | extern int npozzi; 45 | 46 | 47 | void OpenFileInitStruct() { 48 | int i,j; 49 | char namefile[MAXNAMELEN]; 50 | char command[5000]; 51 | /*************************/ 52 | timestamp=0; 53 | outtimestamp=1; 54 | aggregation_cumulate = 0; 55 | num_receives = 0; 56 | global_physical_msgs=0; 57 | 58 | bip= 0; 59 | bip2= 0; 60 | bip3= 0; 61 | bip4= 0; 62 | fires= 0; 63 | loops= 0; 64 | temp=0; 65 | ones= 0; 66 | 67 | idle= 0; 68 | lidle= 0; 69 | lbip2= 0; 70 | check_passed= TRUE; 71 | /* 72 | Finita una computazione e prima di iniziarne un'altra inizializzo 73 | le tabelle delle funzioni e delle costanti. 74 | Questo e' pero' causa di un problema: 75 | se ho fatto una #def perdo le funzioni e le costanti. 76 | Quindi, per ora, e' meglio non riinizializzare ma mettere 77 | MAXNUMCOST e MAXFUNCTIONS alti e fregarsene. 78 | 79 | */ 80 | lift=0; 81 | newval=0; 82 | 83 | #ifdef _DEBUG 84 | TRACING printf("(%d) boot\n",rank); 85 | #endif 86 | lightprocess=(rank+1)%size; 87 | 88 | #ifdef _DEBUG 89 | TRACING printf("(%d) opening log files\n",rank); 90 | #endif 91 | 92 | OUTPUT 93 | { 94 | /* if(inflag==1) { */ 95 | 96 | sprintf(namefile,"DAT/%s.%d.temp.dat",infile,rank); 97 | tempfile= fopen(namefile,"w"); 98 | sprintf(namefile,"DAT/%s.%d.nofires.dat",infile,rank); 99 | nofile= fopen(namefile,"w"); 100 | sprintf(namefile,"DAT/%s.%d.hot.dat",infile,rank); 101 | hotfile= fopen(namefile,"w"); 102 | sprintf(namefile,"DAT/%s.%d.cold.dat",infile,rank); 103 | coldfile= fopen(namefile,"w"); 104 | sprintf(namefile,"DAT/%s.%d.nmm.dat",infile,rank); 105 | anamfile= fopen(namefile,"w"); 106 | for(i=0;i : evaluates the lambda term\n"); 207 | printf(" #open : import the file (pex: default directory)\n"); 208 | printf(" #trace : enable tracing of execution in log files\n"); 209 | printf(" #setloops : set the number of idle loops before ending\n"); 210 | printf(" #setfires : set the maximal number of combustion steps before forcing to end\n"); 211 | } 212 | 213 | void SetOutputFile(char *name) 214 | { 215 | sprintf(outfile,"%s/%s",directoryname,name); 216 | printf("Output File Set: %s\n",outfile); 217 | outflag= 1; 218 | } 219 | 220 | 221 | // This is the code corresponding to the GML-parser 222 | 223 | struct GML_pair*GML_parser(FILE*source,struct GML_stat*stat,int open) 224 | { 225 | struct GML_token token; 226 | struct GML_pair*pair; 227 | struct GML_pair*list; 228 | struct GML_pair*tmp= NULL; 229 | struct GML_list_elem*tmp_elem; 230 | 231 | struct messaggio pozzi[MAXCUTNODES]; 232 | //int npozzi = 0; 233 | 234 | assert(stat); 235 | 236 | pair= (struct GML_pair*)malloc(sizeof(struct GML_pair)); 237 | list= pair; 238 | 239 | for(;;){ 240 | token= GML_scanner(source); 241 | 242 | if(token.kind==GML_END){ 243 | if(open){ 244 | stat->err.err_num= GML_OPEN_BRACKET; 245 | stat->err.line= GML_line; 246 | stat->err.column= GML_column; 247 | free(pair); 248 | 249 | if(tmp==NULL){ 250 | return NULL; 251 | }else{ 252 | tmp->next= NULL; 253 | return list; 254 | } 255 | } 256 | 257 | break; 258 | 259 | }else if(token.kind==GML_R_BRACKET){ 260 | if(!open){ 261 | stat->err.err_num= GML_TOO_MANY_BRACKETS; 262 | stat->err.line= GML_line; 263 | stat->err.column= GML_column; 264 | free(pair); 265 | 266 | if(tmp==NULL){ 267 | return NULL; 268 | }else{ 269 | tmp->next= NULL; 270 | return list; 271 | } 272 | } 273 | 274 | break; 275 | 276 | }else if(token.kind==GML_ERROR){ 277 | stat->err.err_num= token.value.err.err_num; 278 | stat->err.line= token.value.err.line; 279 | stat->err.column= token.value.err.column; 280 | free(pair); 281 | 282 | if(tmp==NULL){ 283 | return NULL; 284 | }else{ 285 | tmp->next= NULL; 286 | return list; 287 | } 288 | 289 | }else if(token.kind!=GML_KEY){ 290 | stat->err.err_num= GML_SYNTAX; 291 | stat->err.line= GML_line; 292 | stat->err.column= GML_column; 293 | free(pair); 294 | 295 | if(token.kind==GML_STRING){ 296 | free(token.value.string); 297 | } 298 | 299 | if(tmp==NULL){ 300 | return NULL; 301 | }else{ 302 | tmp->next= NULL; 303 | return list; 304 | } 305 | } 306 | 307 | if(!stat->key_list){ 308 | stat->key_list= (struct GML_list_elem*) 309 | malloc(sizeof(struct GML_list_elem)); 310 | stat->key_list->next= NULL; 311 | stat->key_list->key= token.value.string; 312 | pair->key= token.value.string; 313 | 314 | }else{ 315 | tmp_elem= stat->key_list; 316 | 317 | while(tmp_elem){ 318 | if(!strcmp(tmp_elem->key,token.value.string)){ 319 | free(token.value.string); 320 | pair->key= tmp_elem->key; 321 | break; 322 | } 323 | 324 | tmp_elem= tmp_elem->next; 325 | } 326 | 327 | if(!tmp_elem){ 328 | tmp_elem= (struct GML_list_elem*) 329 | malloc(sizeof(struct GML_list_elem)); 330 | tmp_elem->next= stat->key_list; 331 | stat->key_list= tmp_elem; 332 | tmp_elem->key= token.value.string; 333 | pair->key= token.value.string; 334 | } 335 | } 336 | 337 | token= GML_scanner(source); 338 | 339 | switch(token.kind){ 340 | case GML_INT: 341 | pair->kind= GML_INT; 342 | pair->value.integer= token.value.integer; 343 | break; 344 | 345 | case GML_DOUBLE: 346 | pair->kind= GML_DOUBLE; 347 | pair->value.floating= token.value.floating; 348 | break; 349 | 350 | case GML_STRING: 351 | pair->kind= GML_STRING; 352 | pair->value.string= token.value.string; 353 | break; 354 | 355 | case GML_L_BRACKET: 356 | pair->kind= GML_LIST; 357 | pair->value.list= GML_parser(source,stat,1); 358 | 359 | if(stat->err.err_num!=GML_OK){ 360 | return list; 361 | } 362 | 363 | break; 364 | 365 | case GML_ERROR: 366 | stat->err.err_num= token.value.err.err_num; 367 | stat->err.line= token.value.err.line; 368 | stat->err.column= token.value.err.column; 369 | free(pair); 370 | 371 | if(tmp==NULL){ 372 | return NULL; 373 | }else{ 374 | tmp->next= NULL; 375 | return list; 376 | } 377 | 378 | default: 379 | stat->err.line= GML_line; 380 | stat->err.column= GML_column; 381 | stat->err.err_num= GML_SYNTAX; 382 | free(pair); 383 | 384 | if(tmp==NULL){ 385 | return NULL; 386 | }else{ 387 | tmp->next= NULL; 388 | return list; 389 | } 390 | } 391 | 392 | tmp= pair; 393 | if(!strcmp(pair->key,"edge")) 394 | { 395 | npozzi= GML_edge_det(pair->value.list,pozzi,npozzi); 396 | }; 397 | pair= (struct GML_pair*)malloc(sizeof(struct GML_pair)); 398 | tmp->next= pair; 399 | } 400 | 401 | stat->err.err_num= GML_OK; 402 | free(pair); 403 | {int i; 404 | if(npozzi>0) 405 | { 406 | printf("\n\n\n"); 407 | for(i= 0;inext= NULL; 422 | return list; 423 | } 424 | } 425 | 426 | 427 | void GML_free_list(struct GML_pair*list,struct GML_list_elem*keys){ 428 | 429 | struct GML_pair*tmp= list; 430 | struct GML_list_elem*tmp_elem; 431 | 432 | while(keys){ 433 | free(keys->key); 434 | tmp_elem= keys; 435 | keys= keys->next; 436 | free(tmp_elem); 437 | } 438 | 439 | while(list){ 440 | 441 | switch(list->kind){ 442 | case GML_LIST: 443 | GML_free_list(list->value.list,NULL); 444 | break; 445 | 446 | case GML_STRING: 447 | free(list->value.string); 448 | break; 449 | 450 | default: 451 | break; 452 | } 453 | 454 | tmp= list; 455 | list= tmp->next; 456 | free(tmp); 457 | } 458 | } 459 | 460 | 461 | 462 | void GML_print_list(struct GML_pair*list,int level){ 463 | 464 | struct GML_pair*tmp= list; 465 | int i; 466 | 467 | while(tmp){ 468 | 469 | for(i= 0;ikey); 474 | 475 | switch(tmp->kind){ 476 | case GML_INT: 477 | printf(" *VALUE* (long) : %ld \n",tmp->value.integer); 478 | break; 479 | 480 | case GML_DOUBLE: 481 | printf(" *VALUE* (double) : %f \n",tmp->value.floating); 482 | break; 483 | 484 | case GML_STRING: 485 | printf(" *VALUE* (string) : %s \n",tmp->value.string); 486 | break; 487 | 488 | case GML_LIST: 489 | printf(" *VALUE* (list) : \n"); 490 | GML_print_list(tmp->value.list,level+1); 491 | break; 492 | 493 | default: 494 | break; 495 | } 496 | 497 | tmp= tmp->next; 498 | } 499 | } 500 | 501 | int GML_edge_det(struct GML_pair*list, struct messaggio*pozzi, int nnpozzi) 502 | { 503 | edge*vsource,*vtarget; 504 | int storeclass,polarity; 505 | 506 | struct messaggio m; 507 | 508 | char weight[MAXLENWEIGHT]; 509 | struct GML_pair*tmp= list; 510 | 511 | printf("AddEdge(%ld,",tmp->value.integer); 512 | printf("%ld,%s,",tmp->next->value.integer,tmp->next->next->value.string); 513 | if(tmp->next->next->next!=NULL){ 514 | printf("OUT)\n"); 515 | storeclass= OUT; 516 | }else 517 | { 518 | printf("IN)\n"); 519 | storeclass= IN; 520 | }; 521 | 522 | { 523 | vsource= NewReference(); 524 | vtarget= NewReference(); 525 | 526 | vsource->creator= size; 527 | vsource->rankpuit= rank; 528 | vsource->source= (node*)tmp->value.integer; 529 | 530 | vtarget->creator= size; 531 | vtarget->rankpuit= rank; 532 | vtarget->source= (node*)tmp->next->value.integer; 533 | // if(size==1) outbuffer= &incoming; 534 | 535 | 536 | if(tmp->next->next->value.string[1]=='+'){ 537 | polarity= LEFT;} 538 | else polarity= RIGHT; 539 | 540 | if(tmp->next->next->value.string[2]=='+'){ 541 | vtarget->side= LEFT;} 542 | else vtarget->side= RIGHT; 543 | 544 | if(tmp->next->next->value.string[0]=='+'){ 545 | storeclass= IN;} 546 | else storeclass= OUT; 547 | 548 | 549 | vsource->sto= storeclass; 550 | 551 | printf("%s\n",(tmp->next->next->value.string)+3); 552 | strcpy(weight,(tmp->next->next->value.string)+3); 553 | 554 | if(tmp->next->next->next!=NULL){ 555 | vtarget->sto= OUT; 556 | vsource->rankpuit= rank; 557 | }else vtarget->sto= IN; 558 | 559 | { 560 | 561 | 562 | StoreMessage(&m,vtarget,vsource,weight,storeclass,polarity); 563 | PushMessage(&m); 564 | if(vtarget->sto==IN)nnpozzi= SinkList(&m,pozzi,nnpozzi); 565 | 566 | }; 567 | }; 568 | return nnpozzi; 569 | } 570 | 571 | 572 | 573 | 574 | /* 575 | * ISO8859-1 coding of chars >= 160 576 | */ 577 | 578 | char* GML_table[] = { 579 | " ", /* 160 */ 580 | "¡", 581 | "¢", 582 | "£", 583 | "¤", 584 | "¥", 585 | "¦", 586 | "§", 587 | "¨", 588 | "©", 589 | "ª", /* 170 */ 590 | "«", 591 | "¬", 592 | "­", 593 | "®", 594 | "¯", 595 | "°", 596 | "±", 597 | "²", 598 | "³", /* 180 */ 599 | "´", 600 | "µ", 601 | "¶", 602 | "·", 603 | "¸", 604 | "¹", 605 | "º", 606 | "»", 607 | "¼", 608 | "½", 609 | "¾", /* 190 */ 610 | "¿", 611 | "À", 612 | "Á", 613 | "Â", 614 | "Ã", 615 | "Ä", 616 | "Å", 617 | "Æ", 618 | "Ç", 619 | "È", /* 200 */ 620 | "É", 621 | "Ê", 622 | "Ë", 623 | "Ì", 624 | "Í", 625 | "Î", 626 | "Ï", 627 | "Ð", 628 | "Ñ", 629 | "Ò", /* 210 */ 630 | "Ó", 631 | "Ô", 632 | "Õ", 633 | "Ö", 634 | "×", 635 | "Ø", 636 | "Ù", 637 | "Ú", 638 | "Û", 639 | "Ü", /* 220 */ 640 | "Ý", 641 | "Þ", 642 | "ß", 643 | "à", 644 | "á", 645 | "â", 646 | "ã", 647 | "ä", 648 | "å", 649 | "æ", /* 230 */ 650 | "ç", 651 | "è", 652 | "é", 653 | "ê", 654 | "ë", 655 | "ì", 656 | "í", 657 | "î", 658 | "ï", 659 | "ð", /* 240 */ 660 | "ñ", 661 | "ò", 662 | "ó", 663 | "ô", 664 | "õ", 665 | "ö", 666 | "÷", 667 | "ø", 668 | "ù", 669 | "ú", /* 250 */ 670 | "û", 671 | "ü", 672 | "ý", 673 | "þ", 674 | "ÿ" 675 | }; 676 | 677 | 678 | 679 | 680 | void GML_init () { 681 | 682 | GML_line = 1; 683 | GML_column = 1; 684 | } 685 | 686 | 687 | 688 | struct GML_token GML_scanner (FILE* source) { 689 | 690 | int cur_max_size = INITIAL_SIZE; 691 | static char buffer[INITIAL_SIZE]; 692 | char* tmp = buffer; 693 | char* ret = tmp; 694 | struct GML_token token; 695 | int is_float = 0; 696 | unsigned int count = 0; 697 | int next; 698 | 699 | assert (source != NULL); 700 | 701 | /* 702 | * eliminate preceeding white spaces 703 | */ 704 | 705 | do { 706 | next = fgetc (source); 707 | GML_column++; 708 | 709 | if (next == '\n') { 710 | GML_line++; 711 | GML_column = 1; 712 | } else if (next == EOF) { 713 | token.kind = GML_END; 714 | return token; 715 | } 716 | } while (isspace (next)); 717 | 718 | if (isdigit (next) || next == '.' || next == '+' || next == '-') { 719 | 720 | /* 721 | * floating point or integer 722 | */ 723 | 724 | do { 725 | if (count == INITIAL_SIZE - 1) { 726 | token.value.err.err_num = GML_TOO_MANY_DIGITS; 727 | token.value.err.line = GML_line; 728 | token.value.err.column = GML_column + count; 729 | token.kind = GML_ERROR; 730 | return token; 731 | } 732 | 733 | if (next == '.' || next == 'E') { 734 | is_float = 1; 735 | } 736 | 737 | buffer[count] = next; 738 | count++; 739 | next = fgetc (source); 740 | } while (!isspace(next)); 741 | 742 | buffer[count] = 0; 743 | 744 | if (next == '\n') { 745 | GML_line++; 746 | GML_column = 1; 747 | } else { 748 | GML_column += count; 749 | } 750 | 751 | if (is_float) { 752 | token.value.floating = atof (tmp); 753 | token.kind = GML_DOUBLE; 754 | } else { 755 | token.value.integer = atol (tmp); 756 | token.kind = GML_INT; 757 | } 758 | 759 | return token; 760 | 761 | } else if (isalpha (next) || next == '_') { 762 | 763 | /* 764 | * key 765 | */ 766 | 767 | do { 768 | if (count == cur_max_size - 1) { 769 | *tmp = 0; 770 | tmp = (char*) malloc(2 * cur_max_size * sizeof (char)); 771 | strcpy (tmp, ret); 772 | 773 | if (cur_max_size > INITIAL_SIZE) { 774 | free (ret); 775 | } 776 | 777 | ret = tmp; 778 | tmp += count; 779 | cur_max_size *= 2; 780 | } 781 | 782 | if (!isalnum (next) && next != '_') { 783 | token.value.err.err_num = GML_UNEXPECTED; 784 | token.value.err.line = GML_line; 785 | token.value.err.column = GML_column + count; 786 | token.kind = GML_ERROR; 787 | 788 | if (cur_max_size > INITIAL_SIZE) { 789 | free (ret); 790 | } 791 | 792 | return token; 793 | } 794 | 795 | *tmp++ = next; 796 | count++; 797 | next = fgetc (source); 798 | } while (!isspace (next) && next != EOF); 799 | 800 | if (next == '\n') { 801 | GML_line++; 802 | GML_column = 1; 803 | } else { 804 | GML_column += count; 805 | } 806 | 807 | *tmp = 0; 808 | token.kind = GML_KEY; 809 | token.value.string = (char*) malloc((count+1) * sizeof (char)); 810 | strcpy (token.value.string, ret); 811 | 812 | if (cur_max_size > INITIAL_SIZE) { 813 | free (ret); 814 | } 815 | 816 | return token; 817 | 818 | } else { 819 | /* 820 | * comments, brackets and strings 821 | */ 822 | 823 | switch (next) { 824 | case '#': 825 | do { 826 | next = fgetc (source); 827 | } while (next != '\n' && next != EOF); 828 | 829 | GML_line++; 830 | GML_column = 1; 831 | return GML_scanner (source); 832 | 833 | case '[': 834 | token.kind = GML_L_BRACKET; 835 | return token; 836 | 837 | case ']': 838 | token.kind = GML_R_BRACKET; 839 | return token; 840 | 841 | case '"': 842 | next = fgetc (source); 843 | GML_column++; 844 | 845 | while (next != '"') { 846 | 847 | if (count >= cur_max_size - 8) { 848 | *tmp = 0; 849 | tmp = (char*) malloc (2 * cur_max_size * sizeof(char)); 850 | strcpy (tmp, ret); 851 | 852 | if (cur_max_size > INITIAL_SIZE) { 853 | free (ret); 854 | } 855 | 856 | ret = tmp; 857 | tmp += count; 858 | cur_max_size *= 2; 859 | } 860 | 861 | if (next >= 160) { 862 | *tmp = 0; 863 | strcat (tmp, GML_table[next - 160]); 864 | count += strlen (GML_table[next - 160]); 865 | tmp = ret + count; 866 | } else { 867 | *tmp++ = next; 868 | count++; 869 | GML_column++; 870 | } 871 | 872 | next = fgetc (source); 873 | 874 | if (next == EOF) { 875 | token.value.err.err_num = GML_PREMATURE_EOF; 876 | token.value.err.line = GML_line; 877 | token.value.err.column = GML_column + count; 878 | token.kind = GML_ERROR; 879 | 880 | if (cur_max_size > INITIAL_SIZE) { 881 | free (ret); 882 | } 883 | 884 | return token; 885 | } 886 | 887 | if (next == '\n') { 888 | GML_line++; 889 | GML_column = 1; 890 | } 891 | } 892 | 893 | *tmp = 0; 894 | token.kind = GML_STRING; 895 | token.value.string = (char*) malloc((count+1) * sizeof (char)); 896 | strcpy (token.value.string, ret); 897 | 898 | if (cur_max_size > INITIAL_SIZE) { 899 | free (ret); 900 | } 901 | 902 | return token; 903 | 904 | default: 905 | token.value.err.err_num = GML_UNEXPECTED; 906 | token.value.err.line = GML_line; 907 | token.value.err.column = GML_column; 908 | token.kind = GML_ERROR; 909 | return token; 910 | } 911 | } 912 | } 913 | 914 | 915 | 916 | int SinkList(m,l,length) 917 | struct messaggio*m; 918 | struct messaggio*l; 919 | int length; 920 | { 921 | int i; 922 | 923 | /* printf("dentro sink\n"); */ 924 | 925 | for(i= 0;i<=length;i++) 926 | if(m->vtarget.source==l[i].vtarget.source){return length;} 927 | 928 | StoreMessage(&l[length],&(m->vtarget),&(m->vtarget),(char*)"*",m->vtarget.sto,m->side); 929 | #ifdef _DEBUG 930 | DEBUG_MEM ShowMessage(&l[length]); 931 | #endif 932 | l[length].tpy= EOT_TAG; 933 | length++; 934 | #ifdef WDEBUG 935 | printf("(%d) number of cut-nodes: %3d",rank,length); 936 | #endif 937 | return length; 938 | } 939 | 940 | -------------------------------------------------------------------------------- /les.fl: -------------------------------------------------------------------------------- 1 | /* Lexical Analyser for the PELCR language 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | %{ 20 | #include "parser.tab.h" 21 | #include 22 | #include "mydefs.h" 23 | #include "gml_parser.h" 24 | //#include "var.h" 25 | 26 | #define MAX_INCLUDE_DEPTH 10 27 | YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; 28 | int linenum[MAX_INCLUDE_DEPTH]; 29 | int include_stack_ptr = 0; 30 | int is_interactive = 1; 31 | %} 32 | 33 | %x incl 34 | %x inclgml 35 | %x COMMENTS 36 | %x INCLCOMMENTS 37 | 38 | /* ANTO */ 39 | 40 | delim [ \t\n] 41 | nl ";" 42 | ws {delim}+ 43 | letter [A-Z_a-z'-] 44 | digit [0-9] 45 | id {letter}({letter}|{digit})* 46 | number {digit}+ 47 | /* ANTO */ 48 | path (\")("."|"/"|{letter})({letter}|{digit}|"/"|".")*(\") 49 | /* ANTO */ 50 | 51 | %% 52 | {ws} {} 53 | "if" {return(IF);} 54 | "then" {return(THEN);} 55 | "else" {return(ELSE);} 56 | "#setloops" {return(SETLOOPS);} 57 | "#setfires" {return(SETFIRES);} 58 | "#quit"|"quit" {return(QUIT);} 59 | "#symbol"|"symbol" {return(SYMBOL);} 60 | "#trace"|"trace" {return(TRACEF);} 61 | "#verbose"|"verbose" {return(VERBOSEF);} 62 | "#uselib"|"#use"|"#include" {return(USELIB);} 63 | "#open"|"#load"|"#import" {BEGIN(incl);} 64 | "#gml" {BEGIN(inclgml);} 65 | "#write" {return(WRITE);} 66 | "#setdir" {return(SETDIR);} 67 | "#status" {return(STATUS);} 68 | "#help" {return(HELP);} 69 | "#def"|"#define" {return(DEF);} 70 | "#xcall" {return (XCALL);} 71 | "rec" {return(REC);} 72 | "let" {return(LET);} 73 | "in" {return(INN);} 74 | "and"|"And"|"or"|"Or"|"Add"|"add"|">"|"mult"|"Mult" { 75 | strcpy(yylval.string,yytext); 76 | return (F2ARG); 77 | } 78 | "xfunction" { 79 | strcpy(yylval.string,yytext); 80 | return (XFUNCTION); 81 | } 82 | "not"|"Not"|"succ"|"Succ"|"pred"|"Pred"|"iszero" { 83 | strcpy(yylval.string,yytext); 84 | return (F1ARG); 85 | } 86 | 87 | "true"|"false"|"TRUE"|"FALSE"|"True"|"False" { strcpy(yylval.string,yytext); 88 | return(BOOLEAN);} 89 | 90 | {id} { 91 | strcpy( yylval.string ,yytext); 92 | return (ID); 93 | } 94 | {number} { 95 | /*yylval.number=atof(yytext);*/ 96 | strcpy(yylval.string,yytext); 97 | return (NUM); 98 | } 99 | 100 | \+|\- { 101 | strcpy(yylval.string,yytext); 102 | return (OP1); 103 | } 104 | \*|\/ { 105 | strcpy(yylval.string,yytext); 106 | return (OP2); 107 | } 108 | {nl} {linenum[include_stack_ptr]++; return (NL);} 109 | \= {return(EQ);} 110 | \( {return('(');} 111 | \) {return(')');} 112 | \[ {return('[');} 113 | \] {return(']');} 114 | \, {return(',');} 115 | \\ {return(LAMBDA);} 116 | \. {return('.');} 117 | 118 | {path} { 119 | strncpy( yylval.string ,yytext+1, yyleng-2); 120 | yylval.string[yyleng-2] = '\0'; 121 | return (PATH); 122 | } 123 | 124 | \/\* { // start of a comment: go to a 'COMMENTS' state. 125 | BEGIN(INCLCOMMENTS); 126 | } 127 | 128 | \/\* { // start of a comment: go to a 'COMMENTS' state. 129 | BEGIN(COMMENTS); 130 | } 131 | 132 | \*\/ { // end of a comment: go back to file including state. 133 | BEGIN(incl); 134 | } 135 | 136 | \*\/ { // end of a comment: go back to normal parsing. 137 | BEGIN(INITIAL); 138 | } 139 | 140 | \n { ++linenum[include_stack_ptr];} 141 | 142 | 143 | \n { ++linenum[include_stack_ptr];} 144 | 145 | . ; // ignore every other character while we are in this state 146 | . ; // ignore every other character while we are in this state 147 | 148 | {path} { 149 | if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) 150 | { 151 | fprintf( stderr, "Includes nested too deeply" ); 152 | exit( 1 ); 153 | } 154 | 155 | include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; 156 | *(yytext + (yyleng-1)) = '\0'; 157 | sprintf(infile,"%s/%s",directoryname,yytext+1); 158 | printf("\n(%d) reading from file %s\n",rank,yytext+1); 159 | yyin = fopen(infile, "r"); 160 | if (!yyin) 161 | { 162 | fprintf( stderr, "\n(%d) cannot open file %s\n",rank,infile); 163 | exit( 1 ); 164 | } 165 | 166 | printf("(%d) filepointer [%p] to %s",rank,(void *)yyin,infile); 167 | 168 | yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) ); 169 | BEGIN(INITIAL); 170 | } 171 | 172 | {path} { 173 | 174 | /*parsing gml*/ 175 | 176 | FILE *gmlfile; 177 | extern int npozzi ; 178 | // struct messaggio pozzi[MAXCUTNODES]; 179 | 180 | struct GML_pair*list; 181 | struct GML_stat*stat= (struct GML_stat*)malloc(sizeof(struct GML_stat)); 182 | stat->key_list= NULL; 183 | 184 | if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) 185 | { 186 | fprintf( stderr, "Includes nested too deeply" ); 187 | exit( 1 ); 188 | } 189 | 190 | include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; 191 | *(yytext + (yyleng-1)) = '\0'; 192 | sprintf(infile,"%s/%s",directoryname,yytext+1); 193 | printf("\n(%d) reading from file %s\n",rank,yytext+1); 194 | 195 | gmlfile = fopen(infile, "r"); 196 | 197 | GML_init(); 198 | list = GML_parser(gmlfile,stat,0); 199 | 200 | if(stat->err.err_num!=GML_OK){ 201 | printf("Error at line %d column %d of %s:\n",stat->err.line,stat->err.column,infile); 202 | 203 | switch(stat->err.err_num){ 204 | case GML_UNEXPECTED: 205 | printf("UNEXPECTED CHARACTER"); 206 | break; 207 | 208 | case GML_SYNTAX: 209 | printf("SYNTAX ERROR"); 210 | break; 211 | 212 | case GML_PREMATURE_EOF: 213 | printf("PREMATURE EOF IN STRING"); 214 | break; 215 | 216 | case GML_TOO_MANY_DIGITS: 217 | printf("NUMBER WITH TOO MANY DIGITS"); 218 | break; 219 | 220 | case GML_OPEN_BRACKET: 221 | printf("OPEN BRACKETS LEFT AT EOF"); 222 | break; 223 | 224 | case GML_TOO_MANY_BRACKETS: 225 | printf("TOO MANY CLOSING BRACKETS"); 226 | break; 227 | 228 | default: 229 | break; 230 | } 231 | GML_free_list(list,stat->key_list); 232 | }; 233 | fclose(gmlfile); 234 | 235 | BDump(&incoming[schedule]); 236 | printf("(%d) exit from initialization procedure, schedule = %d\n",rank,schedule); 237 | printf("(%d) message stack size (of schedule %d) is |%d-%d|=%d\n",rank,schedule,incoming[schedule].last,incoming[schedule].first,incoming[schedule].last-incoming[schedule].first); 238 | printf("(%d) number of target nodes %d\n",rank,npozzi); 239 | BEGIN(INITIAL); 240 | return GMLGRAPH ; 241 | } 242 | 243 | <> { 244 | if ( --include_stack_ptr < 0 ) 245 | { 246 | yyterminate(); 247 | } 248 | else 249 | { 250 | yy_delete_buffer( YY_CURRENT_BUFFER ); 251 | yy_switch_to_buffer(include_stack[include_stack_ptr] ); 252 | } 253 | } 254 | 255 | %% 256 | -------------------------------------------------------------------------------- /les.fl.bak: -------------------------------------------------------------------------------- 1 | /* Lexical Analyser for the PELCR language 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | %{ 20 | #include "parser.tab.h" 21 | #include 22 | #include "mydefs.h" 23 | #include "gml_parser.h" 24 | //#include "var.h" 25 | 26 | #define MAX_INCLUDE_DEPTH 10 27 | YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; 28 | int linenum[MAX_INCLUDE_DEPTH]; 29 | int include_stack_ptr = 0; 30 | int is_interactive = 1; 31 | %} 32 | 33 | %x incl 34 | %x inclgml 35 | %x COMMENTS 36 | %x INCLCOMMENTS 37 | 38 | /* ANTO */ 39 | 40 | delim [ \t\n] 41 | nl ";" 42 | ws {delim}+ 43 | letter [A-Z_a-z'-] 44 | digit [0-9] 45 | id {letter}({letter}|{digit})* 46 | number {digit}+ 47 | /* ANTO */ 48 | path (\")("."|"/"|{letter})({letter}|{digit}|"/"|".")*(\") 49 | /* ANTO */ 50 | 51 | %% 52 | {ws} {} 53 | "if" {return(IF);} 54 | "then" {return(THEN);} 55 | "else" {return(ELSE);} 56 | "#setloops" {return(SETLOOPS);} 57 | "#setfires" {return(SETFIRES);} 58 | "#quit"|"quit" {return(QUIT);} 59 | "#symbol"|"symbol" {return(SYMBOL);} 60 | "#trace"|"trace" {return(TRACEF);} 61 | "#verbose"|"verbose" {return(VERBOSEF);} 62 | "#uselib"|"#use"|"#include" {return(USELIB);} 63 | "#open"|"#load"|"#import" {BEGIN(incl);} 64 | "#gml" {BEGIN(inclgml);} 65 | "#write" {return(WRITE);} 66 | "#setdir" {return(SETDIR);} 67 | "#status" {return(STATUS);} 68 | "#help" {return(HELP);} 69 | "#def"|"#define" {return(DEF);} 70 | "#xcall" {return (XCALL);} 71 | "rec" {return(REC);} 72 | "let" {return(LET);} 73 | "in" {return(INN);} 74 | "and"|"And"|"or"|"Or"|"Add"|"add"|">"|"mult"|"Mult" { 75 | strcpy(yylval.string,yytext); 76 | return (F2ARG); 77 | } 78 | "xfunction" { 79 | strcpy(yylval.string,yytext); 80 | return (XFUNCTION); 81 | } 82 | "not"|"Not"|"succ"|"Succ"|"pred"|"Pred"|"iszero" { 83 | strcpy(yylval.string,yytext); 84 | return (F1ARG); 85 | } 86 | 87 | "true"|"false"|"TRUE"|"FALSE"|"True"|"False" { strcpy(yylval.string,yytext); 88 | return(BOOLEAN);} 89 | 90 | {id} { 91 | strcpy( yylval.string ,yytext); 92 | return (ID); 93 | } 94 | {number} { 95 | /*yylval.number=atof(yytext);*/ 96 | strcpy(yylval.string,yytext); 97 | return (NUM); 98 | } 99 | 100 | \+|\- { 101 | strcpy(yylval.string,yytext); 102 | return (OP1); 103 | } 104 | \*|\/ { 105 | strcpy(yylval.string,yytext); 106 | return (OP2); 107 | } 108 | {nl} {linenum[include_stack_ptr]++; return (NL);} 109 | \= {return(EQ);} 110 | \( {return('(');} 111 | \) {return(')');} 112 | \[ {return('[');} 113 | \] {return(']');} 114 | \, {return(',');} 115 | \\ {return(LAMBDA);} 116 | \. {return('.');} 117 | 118 | {path} { 119 | strncpy( yylval.string ,yytext+1, yyleng-2); 120 | yylval.string[yyleng-2] = '\0'; 121 | return (PATH); 122 | } 123 | 124 | \/\* { // start of a comment: go to a 'COMMENTS' state. 125 | BEGIN(INCLCOMMENTS); 126 | } 127 | 128 | \/\* { // start of a comment: go to a 'COMMENTS' state. 129 | BEGIN(COMMENTS); 130 | } 131 | 132 | \*\/ { // end of a comment: go back to file including state. 133 | BEGIN(incl); 134 | } 135 | \*\/ { // end of a comment: go back to normal parsing. 136 | BEGIN(INITIAL); 137 | } 138 | \n { ++linenum[include_stack_ptr];} 139 | . ; // ignore every other character while we're in this state 140 | 141 | \n { ++linenum[include_stack_ptr];} 142 | . ; // ignore every other character while we're in this state 143 | 144 | 145 | {path} { 146 | if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) 147 | { 148 | fprintf( stderr, "Includes nested too deeply" ); 149 | exit( 1 ); 150 | } 151 | 152 | include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; 153 | *(yytext + (yyleng-1)) = '\0'; 154 | sprintf(infile,"%s/%s",directoryname,yytext+1); 155 | printf("\n(%d) reading from file %s\n",rank,yytext+1); 156 | yyin = fopen(infile, "r"); 157 | if (!yyin) 158 | { 159 | fprintf( stderr, "\n(%d) cannot open file %s\n",rank,infile); 160 | exit( 1 ); 161 | } 162 | 163 | printf("(%d) filepointer [%p] to %s",rank,(void *)yyin,infile); 164 | 165 | yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) ); 166 | BEGIN(INITIAL); 167 | } 168 | 169 | {path} { 170 | 171 | /*parsing gml*/ 172 | 173 | FILE *gmlfile; 174 | // int npozzi = 0 ; 175 | // struct messaggio pozzi[MAXCUTNODES]; 176 | 177 | struct GML_pair*list; 178 | struct GML_stat*stat= (struct GML_stat*)malloc(sizeof(struct GML_stat)); 179 | stat->key_list= NULL; 180 | 181 | if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) 182 | { 183 | fprintf( stderr, "Includes nested too deeply" ); 184 | exit( 1 ); 185 | } 186 | 187 | include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; 188 | *(yytext + (yyleng-1)) = '\0'; 189 | sprintf(infile,"%s/%s",directoryname,yytext+1); 190 | printf("\n(%d) reading from file %s\n",rank,yytext+1); 191 | 192 | gmlfile = fopen(infile, "r"); 193 | 194 | GML_init(); 195 | list = GML_parser(gmlfile,stat,0); 196 | 197 | if(stat->err.err_num!=GML_OK){ 198 | printf("Error at line %d column %d of %s:\n",stat->err.line,stat->err.column,infile); 199 | 200 | switch(stat->err.err_num){ 201 | case GML_UNEXPECTED: 202 | printf("UNEXPECTED CHARACTER"); 203 | break; 204 | 205 | case GML_SYNTAX: 206 | printf("SYNTAX ERROR"); 207 | break; 208 | 209 | case GML_PREMATURE_EOF: 210 | printf("PREMATURE EOF IN STRING"); 211 | break; 212 | 213 | case GML_TOO_MANY_DIGITS: 214 | printf("NUMBER WITH TOO MANY DIGITS"); 215 | break; 216 | 217 | case GML_OPEN_BRACKET: 218 | printf("OPEN BRACKETS LEFT AT EOF"); 219 | break; 220 | 221 | case GML_TOO_MANY_BRACKETS: 222 | printf("TOO MANY CLOSING BRACKETS"); 223 | break; 224 | 225 | default: 226 | break; 227 | } 228 | GML_free_list(list,stat->key_list); 229 | }; 230 | fclose(gmlfile); 231 | 232 | BDump(&incoming[schedule]); 233 | printf("(%d) exit from initialization procedure, schedule = %d\n",rank,schedule); 234 | printf("(%d) message stack size (of schedule %d) is |%d-%d|=%d\n",rank,schedule,incoming[schedule].last,incoming[schedule].first,incoming[schedule].last-incoming[schedule].first); 235 | printf("(%d) number of target nodes %d\n",rank,npozzi); 236 | BEGIN(INITIAL); 237 | return GMLGRAPH ; 238 | } 239 | 240 | <> { 241 | if ( --include_stack_ptr < 0 ) 242 | { 243 | yyterminate(); 244 | } 245 | else 246 | { 247 | yy_delete_buffer( YY_CURRENT_BUFFER ); 248 | yy_switch_to_buffer(include_stack[include_stack_ptr] ); 249 | } 250 | } 251 | 252 | 253 | 254 | %% 255 | 256 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | /* Main part of the source code: interpretation of commandline options, 2 | starting of execution, printing of messages. 3 | 4 | Copyright (C) 1997-2015 Marco Pedicini 5 | 6 | This file is part of PELCR. 7 | 8 | PELCR is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | PELCR is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with PELCR. If not, see . */ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | #ifdef SOLARIS 26 | #include 27 | #endif 28 | #include 29 | #include 30 | #ifdef MPE_GRAPH 31 | #include 32 | #endif 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | //#include 40 | 41 | //#include "mydefs.h" 42 | //#include "symbolic.h" 43 | //#include "graph.h" 44 | //#include "combustion.h" 45 | //#include "y.tab.h" 46 | //#include "io.h" 47 | //#include "dvm.h" 48 | //#include "distribution.h" 49 | //#include "lambdastar.h" 50 | //#include "buildgraph.h" 51 | #include "var.h" 52 | 53 | extern int yyparse (void); 54 | 55 | int main(int argc, char **argv) { 56 | int j; 57 | int fine=0; 58 | 59 | timestamp = 0; 60 | outtimestamp=1; 61 | aggregation_cumulate = 0; 62 | num_receives = 0; 63 | 64 | global_physical_msgs=0; 65 | 66 | pflag=0 ; 67 | 68 | traceflag=0; 69 | inflag=0; 70 | outflag=0; 71 | verflag=0; 72 | 73 | bip= 0; 74 | bip2= 0; 75 | bip3= 0; 76 | bip4= 0; 77 | fires= 0; 78 | loops= 0; 79 | prnsteps= 1; 80 | ones= 0; 81 | unaddtest= 0; 82 | uneottest= 0; 83 | laddtest= 0; 84 | leottest= 0; 85 | idle= 0; 86 | lidle= 0; 87 | lbip2= 0; 88 | francesco= 0; 89 | lastloop= 0; 90 | 91 | ending= 0; 92 | end_computation= 0; 93 | check_passed= TRUE; 94 | 95 | maxubound =1 ; 96 | local_pending = 0; 97 | edges_counter=0; 98 | inittime=0; 99 | finaltime=0; 100 | contatore_combustioni_f = 0; 101 | lift=0; 102 | varname=0; 103 | symbolTable=NULL; 104 | 105 | kindex=-1; 106 | findex=-1; 107 | fcounter=-1; 108 | 109 | for (j=0; j=1)) { 221 | MPI_Comm_rank(MPI_COMM_WORLD,&rank); 222 | 223 | fine=0; 224 | 225 | if INITIALIZER { 226 | printf("PELCR (Parallel Environment for Lambda Calculus Optimal Reduction)\n"); 227 | printf(" C. Giuffrida, M. Pedicini, F. Quaglia \n"); 228 | printf(" IAC - CNR (Rome, 1996 - 2002)\n"); 229 | }; 230 | 231 | /*** INTERPRETER MAIN LOOP ***/ 232 | while (fine!=MAXNUMCOST+1) { 233 | printf("(%d) EVAL\n",rank); 234 | OpenFileInitStruct(); fflush(stdout); 235 | if INITIALIZER { 236 | printf("(%d) PELCR 10.0> ",rank); fflush(stdout); 237 | /* CALLING PARSER */ 238 | fine = yyparse(); 239 | // printf("(%d) loops %ld\n",rank,maxloop); fflush(stdout); 240 | 241 | /* BROADCAST TO MPICOMMWORLD RENDEZ-VOUS POINT AFTER PARSING*/ 242 | MPI_Bcast(&fine,1,MPI_INT,0,MPI_COMM_WORLD); 243 | if (fine!=MAXNUMCOST+1) { 244 | BDump(&incoming[schedule]); 245 | /*MPI_Barrier(MPI_COMM_WORLD);*/ 246 | number_of_processes=size; 247 | OUTPUT printf("(%d) initial network created\n",rank); 248 | OUTPUT printf("(%d) n. of activated processes %d\n",rank,number_of_processes); 249 | environment= NULL; 250 | TRACING fprintf(logfile,"(%d) COLDS=[%p] HOTS=[%p]\n",rank,(void*)G.cold,(void*)G.hot); 251 | /*DEBUG Print(G,incoming,bip3);*/ 252 | } 253 | } 254 | if WARMING { 255 | MPI_Bcast(&fine,1,MPI_INT,0,MPI_COMM_WORLD); 256 | if (fine!=MAXNUMCOST+1) { 257 | kindex=fine; 258 | /*MPI_Barrier(MPI_COMM_WORLD);*/ 259 | } 260 | } 261 | 262 | MPI_Barrier(MPI_COMM_WORLD); 263 | if (fine!=MAXNUMCOST+1) { 264 | TRACING fprintf(logfile,"2nd Barrier passed - injecting the stream of actions corresponding to the parsed term\n"); 265 | printf("(%d) 2nd barrier - injecting the stream of actions corresponding to the parsed term\n",rank);fflush(stdout); 266 | 267 | /* set to zero the counter for beta-reductions */ 268 | /* number of LAMBDA-APP reductions (families in the Levy's sense) */ 269 | fam_counter = 0 ; 270 | buf_flush(); /* scheduler*/ 271 | 272 | if (size!=1) loops = 0; 273 | tim = time(&inittime); 274 | 275 | /* ANTO */ 276 | BCastLoad(); 277 | 278 | /* READY TO START EVALUATION */ 279 | MPI_Barrier(MPI_COMM_WORLD); 280 | TRACING fprintf(logfile,"3nd Barrier passed - starting the distributed computing engine\n"); 281 | printf("(%d) 3rd barrier - starting the distributed computing engine\n",rank); 282 | fflush(stdout); 283 | 284 | /* START */ 285 | ComputeResult(); 286 | TRACING fprintf(logfile,"(%d) finished - collecting results\n",rank); 287 | printf("(%d) finished - collecting results\n",rank); 288 | /* PRINT AFTER EVALUATING */ 289 | PrintResult(); 290 | 291 | if INITIALIZER 292 | if (newval) printf("Result: %lld\n",k[kindex][1]); 293 | MostraTabelle(); fflush(stdout); 294 | #ifdef WDEBUG 295 | /*{long int f; for(f=0;f<500000000;f++);}*/ 296 | #endif 297 | } 298 | } 299 | } 300 | printf("\n(%d) QUIT\n",rank); 301 | CloseLib(); 302 | Finally(); 303 | fflush(stdout); 304 | return 0; 305 | } 306 | 307 | -------------------------------------------------------------------------------- /parser.output: -------------------------------------------------------------------------------- 1 | Terminals which are not used 2 | 3 | OP1 4 | OP2 5 | LOP1 6 | LOP2 7 | 8 | 9 | Grammar 10 | 11 | 0 $accept: lines $end 12 | 13 | 1 lines: lines line 14 | 2 | line 15 | 16 | 3 line: lterm NL 17 | 4 | stmt NL 18 | 5 | error 19 | 20 | 6 stmt: QUIT 21 | 7 | SYMBOL 22 | 8 | TRACEF 23 | 9 | VERBOSEF 24 | 10 | SETLOOPS NUM 25 | 11 | SETFIRES NUM 26 | 12 | WRITE PATH 27 | 13 | USELIB PATH 28 | 14 | XCALL '(' ID ')' '(' PATH ')' 29 | 15 | XCALL '(' ID ')' '(' NUM ')' 30 | 16 | DEF ID EQ lterm 31 | 17 | SETDIR PATH 32 | 18 | STATUS 33 | 19 | HELP 34 | 20 | GMLGRAPH 35 | 36 | 21 lterm: LAMBDA ID '.' lterm 37 | 22 | '(' lterm ')' lterm 38 | 23 | ID 39 | 24 | NUM 40 | 25 | BOOLEAN 41 | 26 | F1ARG '(' lterm ')' 42 | 27 | F2ARG '(' lterm ',' lterm ')' 43 | 28 | XFUNCTION '(' ID ')' '(' lterm ')' 44 | 29 | XFUNCTION '(' ID ')' '(' lterm ',' lterm ')' 45 | 30 | IF lterm THEN lterm ELSE lterm 46 | 31 | LET ID EQ lterm INN lterm 47 | 32 | REC ID INN lterm 48 | 49 | 50 | Terminals, with rules where they appear 51 | 52 | $end (0) 0 53 | '(' (40) 14 15 22 26 27 28 29 54 | ')' (41) 14 15 22 26 27 28 29 55 | ',' (44) 27 29 56 | '.' (46) 21 57 | error (256) 5 58 | HELP (258) 19 59 | TRACEF (259) 8 60 | VERBOSEF (260) 9 61 | USELIB (261) 13 62 | QUIT (262) 6 63 | WRITE (263) 12 64 | SETDIR (264) 17 65 | SETLOOPS (265) 10 66 | SETFIRES (266) 11 67 | STATUS (267) 18 68 | SYMBOL (268) 7 69 | REC (269) 32 70 | DEF (270) 16 71 | IF (271) 30 72 | THEN (272) 30 73 | ELSE (273) 30 74 | GMLGRAPH (274) 20 75 | NL (275) 3 4 76 | EQ (276) 16 31 77 | LAMBDA (277) 21 78 | OP1 (278) 79 | OP2 (279) 80 | ID (280) 14 15 16 21 23 28 29 31 32 81 | LOP1 (281) 82 | LOP2 (282) 83 | NUM (283) 10 11 15 24 84 | BOOLEAN (284) 25 85 | F1ARG (285) 26 86 | F2ARG (286) 27 87 | XFUNCTION (287) 28 29 88 | LET (288) 31 89 | INN (289) 31 32 90 | PATH (290) 12 13 14 17 91 | XCALL (291) 14 15 92 | 93 | 94 | Nonterminals, with rules where they appear 95 | 96 | $accept (41) 97 | on left: 0 98 | lines (42) 99 | on left: 1 2, on right: 0 1 100 | line (43) 101 | on left: 3 4 5, on right: 1 2 102 | stmt (44) 103 | on left: 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20, 104 | on right: 4 105 | lterm (45) 106 | on left: 21 22 23 24 25 26 27 28 29 30 31 32, on right: 3 16 21 107 | 22 26 27 28 29 30 31 32 108 | 109 | 110 | state 0 111 | 112 | 0 $accept: . lines $end 113 | 114 | error shift, and go to state 1 115 | HELP shift, and go to state 2 116 | TRACEF shift, and go to state 3 117 | VERBOSEF shift, and go to state 4 118 | USELIB shift, and go to state 5 119 | QUIT shift, and go to state 6 120 | WRITE shift, and go to state 7 121 | SETDIR shift, and go to state 8 122 | SETLOOPS shift, and go to state 9 123 | SETFIRES shift, and go to state 10 124 | STATUS shift, and go to state 11 125 | SYMBOL shift, and go to state 12 126 | REC shift, and go to state 13 127 | DEF shift, and go to state 14 128 | IF shift, and go to state 15 129 | GMLGRAPH shift, and go to state 16 130 | LAMBDA shift, and go to state 17 131 | ID shift, and go to state 18 132 | NUM shift, and go to state 19 133 | BOOLEAN shift, and go to state 20 134 | F1ARG shift, and go to state 21 135 | F2ARG shift, and go to state 22 136 | XFUNCTION shift, and go to state 23 137 | LET shift, and go to state 24 138 | XCALL shift, and go to state 25 139 | '(' shift, and go to state 26 140 | 141 | lines go to state 27 142 | line go to state 28 143 | stmt go to state 29 144 | lterm go to state 30 145 | 146 | 147 | state 1 148 | 149 | 5 line: error . 150 | 151 | $default reduce using rule 5 (line) 152 | 153 | 154 | state 2 155 | 156 | 19 stmt: HELP . 157 | 158 | $default reduce using rule 19 (stmt) 159 | 160 | 161 | state 3 162 | 163 | 8 stmt: TRACEF . 164 | 165 | $default reduce using rule 8 (stmt) 166 | 167 | 168 | state 4 169 | 170 | 9 stmt: VERBOSEF . 171 | 172 | $default reduce using rule 9 (stmt) 173 | 174 | 175 | state 5 176 | 177 | 13 stmt: USELIB . PATH 178 | 179 | PATH shift, and go to state 31 180 | 181 | 182 | state 6 183 | 184 | 6 stmt: QUIT . 185 | 186 | $default reduce using rule 6 (stmt) 187 | 188 | 189 | state 7 190 | 191 | 12 stmt: WRITE . PATH 192 | 193 | PATH shift, and go to state 32 194 | 195 | 196 | state 8 197 | 198 | 17 stmt: SETDIR . PATH 199 | 200 | PATH shift, and go to state 33 201 | 202 | 203 | state 9 204 | 205 | 10 stmt: SETLOOPS . NUM 206 | 207 | NUM shift, and go to state 34 208 | 209 | 210 | state 10 211 | 212 | 11 stmt: SETFIRES . NUM 213 | 214 | NUM shift, and go to state 35 215 | 216 | 217 | state 11 218 | 219 | 18 stmt: STATUS . 220 | 221 | $default reduce using rule 18 (stmt) 222 | 223 | 224 | state 12 225 | 226 | 7 stmt: SYMBOL . 227 | 228 | $default reduce using rule 7 (stmt) 229 | 230 | 231 | state 13 232 | 233 | 32 lterm: REC . ID INN lterm 234 | 235 | ID shift, and go to state 36 236 | 237 | 238 | state 14 239 | 240 | 16 stmt: DEF . ID EQ lterm 241 | 242 | ID shift, and go to state 37 243 | 244 | 245 | state 15 246 | 247 | 30 lterm: IF . lterm THEN lterm ELSE lterm 248 | 249 | REC shift, and go to state 13 250 | IF shift, and go to state 15 251 | LAMBDA shift, and go to state 17 252 | ID shift, and go to state 18 253 | NUM shift, and go to state 19 254 | BOOLEAN shift, and go to state 20 255 | F1ARG shift, and go to state 21 256 | F2ARG shift, and go to state 22 257 | XFUNCTION shift, and go to state 23 258 | LET shift, and go to state 24 259 | '(' shift, and go to state 26 260 | 261 | lterm go to state 38 262 | 263 | 264 | state 16 265 | 266 | 20 stmt: GMLGRAPH . 267 | 268 | $default reduce using rule 20 (stmt) 269 | 270 | 271 | state 17 272 | 273 | 21 lterm: LAMBDA . ID '.' lterm 274 | 275 | ID shift, and go to state 39 276 | 277 | 278 | state 18 279 | 280 | 23 lterm: ID . 281 | 282 | $default reduce using rule 23 (lterm) 283 | 284 | 285 | state 19 286 | 287 | 24 lterm: NUM . 288 | 289 | $default reduce using rule 24 (lterm) 290 | 291 | 292 | state 20 293 | 294 | 25 lterm: BOOLEAN . 295 | 296 | $default reduce using rule 25 (lterm) 297 | 298 | 299 | state 21 300 | 301 | 26 lterm: F1ARG . '(' lterm ')' 302 | 303 | '(' shift, and go to state 40 304 | 305 | 306 | state 22 307 | 308 | 27 lterm: F2ARG . '(' lterm ',' lterm ')' 309 | 310 | '(' shift, and go to state 41 311 | 312 | 313 | state 23 314 | 315 | 28 lterm: XFUNCTION . '(' ID ')' '(' lterm ')' 316 | 29 | XFUNCTION . '(' ID ')' '(' lterm ',' lterm ')' 317 | 318 | '(' shift, and go to state 42 319 | 320 | 321 | state 24 322 | 323 | 31 lterm: LET . ID EQ lterm INN lterm 324 | 325 | ID shift, and go to state 43 326 | 327 | 328 | state 25 329 | 330 | 14 stmt: XCALL . '(' ID ')' '(' PATH ')' 331 | 15 | XCALL . '(' ID ')' '(' NUM ')' 332 | 333 | '(' shift, and go to state 44 334 | 335 | 336 | state 26 337 | 338 | 22 lterm: '(' . lterm ')' lterm 339 | 340 | REC shift, and go to state 13 341 | IF shift, and go to state 15 342 | LAMBDA shift, and go to state 17 343 | ID shift, and go to state 18 344 | NUM shift, and go to state 19 345 | BOOLEAN shift, and go to state 20 346 | F1ARG shift, and go to state 21 347 | F2ARG shift, and go to state 22 348 | XFUNCTION shift, and go to state 23 349 | LET shift, and go to state 24 350 | '(' shift, and go to state 26 351 | 352 | lterm go to state 45 353 | 354 | 355 | state 27 356 | 357 | 0 $accept: lines . $end 358 | 1 lines: lines . line 359 | 360 | $end shift, and go to state 46 361 | error shift, and go to state 1 362 | HELP shift, and go to state 2 363 | TRACEF shift, and go to state 3 364 | VERBOSEF shift, and go to state 4 365 | USELIB shift, and go to state 5 366 | QUIT shift, and go to state 6 367 | WRITE shift, and go to state 7 368 | SETDIR shift, and go to state 8 369 | SETLOOPS shift, and go to state 9 370 | SETFIRES shift, and go to state 10 371 | STATUS shift, and go to state 11 372 | SYMBOL shift, and go to state 12 373 | REC shift, and go to state 13 374 | DEF shift, and go to state 14 375 | IF shift, and go to state 15 376 | GMLGRAPH shift, and go to state 16 377 | LAMBDA shift, and go to state 17 378 | ID shift, and go to state 18 379 | NUM shift, and go to state 19 380 | BOOLEAN shift, and go to state 20 381 | F1ARG shift, and go to state 21 382 | F2ARG shift, and go to state 22 383 | XFUNCTION shift, and go to state 23 384 | LET shift, and go to state 24 385 | XCALL shift, and go to state 25 386 | '(' shift, and go to state 26 387 | 388 | line go to state 47 389 | stmt go to state 29 390 | lterm go to state 30 391 | 392 | 393 | state 28 394 | 395 | 2 lines: line . 396 | 397 | $default reduce using rule 2 (lines) 398 | 399 | 400 | state 29 401 | 402 | 4 line: stmt . NL 403 | 404 | NL shift, and go to state 48 405 | 406 | 407 | state 30 408 | 409 | 3 line: lterm . NL 410 | 411 | NL shift, and go to state 49 412 | 413 | 414 | state 31 415 | 416 | 13 stmt: USELIB PATH . 417 | 418 | $default reduce using rule 13 (stmt) 419 | 420 | 421 | state 32 422 | 423 | 12 stmt: WRITE PATH . 424 | 425 | $default reduce using rule 12 (stmt) 426 | 427 | 428 | state 33 429 | 430 | 17 stmt: SETDIR PATH . 431 | 432 | $default reduce using rule 17 (stmt) 433 | 434 | 435 | state 34 436 | 437 | 10 stmt: SETLOOPS NUM . 438 | 439 | $default reduce using rule 10 (stmt) 440 | 441 | 442 | state 35 443 | 444 | 11 stmt: SETFIRES NUM . 445 | 446 | $default reduce using rule 11 (stmt) 447 | 448 | 449 | state 36 450 | 451 | 32 lterm: REC ID . INN lterm 452 | 453 | INN shift, and go to state 50 454 | 455 | 456 | state 37 457 | 458 | 16 stmt: DEF ID . EQ lterm 459 | 460 | EQ shift, and go to state 51 461 | 462 | 463 | state 38 464 | 465 | 30 lterm: IF lterm . THEN lterm ELSE lterm 466 | 467 | THEN shift, and go to state 52 468 | 469 | 470 | state 39 471 | 472 | 21 lterm: LAMBDA ID . '.' lterm 473 | 474 | '.' shift, and go to state 53 475 | 476 | 477 | state 40 478 | 479 | 26 lterm: F1ARG '(' . lterm ')' 480 | 481 | REC shift, and go to state 13 482 | IF shift, and go to state 15 483 | LAMBDA shift, and go to state 17 484 | ID shift, and go to state 18 485 | NUM shift, and go to state 19 486 | BOOLEAN shift, and go to state 20 487 | F1ARG shift, and go to state 21 488 | F2ARG shift, and go to state 22 489 | XFUNCTION shift, and go to state 23 490 | LET shift, and go to state 24 491 | '(' shift, and go to state 26 492 | 493 | lterm go to state 54 494 | 495 | 496 | state 41 497 | 498 | 27 lterm: F2ARG '(' . lterm ',' lterm ')' 499 | 500 | REC shift, and go to state 13 501 | IF shift, and go to state 15 502 | LAMBDA shift, and go to state 17 503 | ID shift, and go to state 18 504 | NUM shift, and go to state 19 505 | BOOLEAN shift, and go to state 20 506 | F1ARG shift, and go to state 21 507 | F2ARG shift, and go to state 22 508 | XFUNCTION shift, and go to state 23 509 | LET shift, and go to state 24 510 | '(' shift, and go to state 26 511 | 512 | lterm go to state 55 513 | 514 | 515 | state 42 516 | 517 | 28 lterm: XFUNCTION '(' . ID ')' '(' lterm ')' 518 | 29 | XFUNCTION '(' . ID ')' '(' lterm ',' lterm ')' 519 | 520 | ID shift, and go to state 56 521 | 522 | 523 | state 43 524 | 525 | 31 lterm: LET ID . EQ lterm INN lterm 526 | 527 | EQ shift, and go to state 57 528 | 529 | 530 | state 44 531 | 532 | 14 stmt: XCALL '(' . ID ')' '(' PATH ')' 533 | 15 | XCALL '(' . ID ')' '(' NUM ')' 534 | 535 | ID shift, and go to state 58 536 | 537 | 538 | state 45 539 | 540 | 22 lterm: '(' lterm . ')' lterm 541 | 542 | ')' shift, and go to state 59 543 | 544 | 545 | state 46 546 | 547 | 0 $accept: lines $end . 548 | 549 | $default accept 550 | 551 | 552 | state 47 553 | 554 | 1 lines: lines line . 555 | 556 | $default reduce using rule 1 (lines) 557 | 558 | 559 | state 48 560 | 561 | 4 line: stmt NL . 562 | 563 | $default reduce using rule 4 (line) 564 | 565 | 566 | state 49 567 | 568 | 3 line: lterm NL . 569 | 570 | $default reduce using rule 3 (line) 571 | 572 | 573 | state 50 574 | 575 | 32 lterm: REC ID INN . lterm 576 | 577 | REC shift, and go to state 13 578 | IF shift, and go to state 15 579 | LAMBDA shift, and go to state 17 580 | ID shift, and go to state 18 581 | NUM shift, and go to state 19 582 | BOOLEAN shift, and go to state 20 583 | F1ARG shift, and go to state 21 584 | F2ARG shift, and go to state 22 585 | XFUNCTION shift, and go to state 23 586 | LET shift, and go to state 24 587 | '(' shift, and go to state 26 588 | 589 | lterm go to state 60 590 | 591 | 592 | state 51 593 | 594 | 16 stmt: DEF ID EQ . lterm 595 | 596 | REC shift, and go to state 13 597 | IF shift, and go to state 15 598 | LAMBDA shift, and go to state 17 599 | ID shift, and go to state 18 600 | NUM shift, and go to state 19 601 | BOOLEAN shift, and go to state 20 602 | F1ARG shift, and go to state 21 603 | F2ARG shift, and go to state 22 604 | XFUNCTION shift, and go to state 23 605 | LET shift, and go to state 24 606 | '(' shift, and go to state 26 607 | 608 | lterm go to state 61 609 | 610 | 611 | state 52 612 | 613 | 30 lterm: IF lterm THEN . lterm ELSE lterm 614 | 615 | REC shift, and go to state 13 616 | IF shift, and go to state 15 617 | LAMBDA shift, and go to state 17 618 | ID shift, and go to state 18 619 | NUM shift, and go to state 19 620 | BOOLEAN shift, and go to state 20 621 | F1ARG shift, and go to state 21 622 | F2ARG shift, and go to state 22 623 | XFUNCTION shift, and go to state 23 624 | LET shift, and go to state 24 625 | '(' shift, and go to state 26 626 | 627 | lterm go to state 62 628 | 629 | 630 | state 53 631 | 632 | 21 lterm: LAMBDA ID '.' . lterm 633 | 634 | REC shift, and go to state 13 635 | IF shift, and go to state 15 636 | LAMBDA shift, and go to state 17 637 | ID shift, and go to state 18 638 | NUM shift, and go to state 19 639 | BOOLEAN shift, and go to state 20 640 | F1ARG shift, and go to state 21 641 | F2ARG shift, and go to state 22 642 | XFUNCTION shift, and go to state 23 643 | LET shift, and go to state 24 644 | '(' shift, and go to state 26 645 | 646 | lterm go to state 63 647 | 648 | 649 | state 54 650 | 651 | 26 lterm: F1ARG '(' lterm . ')' 652 | 653 | ')' shift, and go to state 64 654 | 655 | 656 | state 55 657 | 658 | 27 lterm: F2ARG '(' lterm . ',' lterm ')' 659 | 660 | ',' shift, and go to state 65 661 | 662 | 663 | state 56 664 | 665 | 28 lterm: XFUNCTION '(' ID . ')' '(' lterm ')' 666 | 29 | XFUNCTION '(' ID . ')' '(' lterm ',' lterm ')' 667 | 668 | ')' shift, and go to state 66 669 | 670 | 671 | state 57 672 | 673 | 31 lterm: LET ID EQ . lterm INN lterm 674 | 675 | REC shift, and go to state 13 676 | IF shift, and go to state 15 677 | LAMBDA shift, and go to state 17 678 | ID shift, and go to state 18 679 | NUM shift, and go to state 19 680 | BOOLEAN shift, and go to state 20 681 | F1ARG shift, and go to state 21 682 | F2ARG shift, and go to state 22 683 | XFUNCTION shift, and go to state 23 684 | LET shift, and go to state 24 685 | '(' shift, and go to state 26 686 | 687 | lterm go to state 67 688 | 689 | 690 | state 58 691 | 692 | 14 stmt: XCALL '(' ID . ')' '(' PATH ')' 693 | 15 | XCALL '(' ID . ')' '(' NUM ')' 694 | 695 | ')' shift, and go to state 68 696 | 697 | 698 | state 59 699 | 700 | 22 lterm: '(' lterm ')' . lterm 701 | 702 | REC shift, and go to state 13 703 | IF shift, and go to state 15 704 | LAMBDA shift, and go to state 17 705 | ID shift, and go to state 18 706 | NUM shift, and go to state 19 707 | BOOLEAN shift, and go to state 20 708 | F1ARG shift, and go to state 21 709 | F2ARG shift, and go to state 22 710 | XFUNCTION shift, and go to state 23 711 | LET shift, and go to state 24 712 | '(' shift, and go to state 26 713 | 714 | lterm go to state 69 715 | 716 | 717 | state 60 718 | 719 | 32 lterm: REC ID INN lterm . 720 | 721 | $default reduce using rule 32 (lterm) 722 | 723 | 724 | state 61 725 | 726 | 16 stmt: DEF ID EQ lterm . 727 | 728 | $default reduce using rule 16 (stmt) 729 | 730 | 731 | state 62 732 | 733 | 30 lterm: IF lterm THEN lterm . ELSE lterm 734 | 735 | ELSE shift, and go to state 70 736 | 737 | 738 | state 63 739 | 740 | 21 lterm: LAMBDA ID '.' lterm . 741 | 742 | $default reduce using rule 21 (lterm) 743 | 744 | 745 | state 64 746 | 747 | 26 lterm: F1ARG '(' lterm ')' . 748 | 749 | $default reduce using rule 26 (lterm) 750 | 751 | 752 | state 65 753 | 754 | 27 lterm: F2ARG '(' lterm ',' . lterm ')' 755 | 756 | REC shift, and go to state 13 757 | IF shift, and go to state 15 758 | LAMBDA shift, and go to state 17 759 | ID shift, and go to state 18 760 | NUM shift, and go to state 19 761 | BOOLEAN shift, and go to state 20 762 | F1ARG shift, and go to state 21 763 | F2ARG shift, and go to state 22 764 | XFUNCTION shift, and go to state 23 765 | LET shift, and go to state 24 766 | '(' shift, and go to state 26 767 | 768 | lterm go to state 71 769 | 770 | 771 | state 66 772 | 773 | 28 lterm: XFUNCTION '(' ID ')' . '(' lterm ')' 774 | 29 | XFUNCTION '(' ID ')' . '(' lterm ',' lterm ')' 775 | 776 | '(' shift, and go to state 72 777 | 778 | 779 | state 67 780 | 781 | 31 lterm: LET ID EQ lterm . INN lterm 782 | 783 | INN shift, and go to state 73 784 | 785 | 786 | state 68 787 | 788 | 14 stmt: XCALL '(' ID ')' . '(' PATH ')' 789 | 15 | XCALL '(' ID ')' . '(' NUM ')' 790 | 791 | '(' shift, and go to state 74 792 | 793 | 794 | state 69 795 | 796 | 22 lterm: '(' lterm ')' lterm . 797 | 798 | $default reduce using rule 22 (lterm) 799 | 800 | 801 | state 70 802 | 803 | 30 lterm: IF lterm THEN lterm ELSE . lterm 804 | 805 | REC shift, and go to state 13 806 | IF shift, and go to state 15 807 | LAMBDA shift, and go to state 17 808 | ID shift, and go to state 18 809 | NUM shift, and go to state 19 810 | BOOLEAN shift, and go to state 20 811 | F1ARG shift, and go to state 21 812 | F2ARG shift, and go to state 22 813 | XFUNCTION shift, and go to state 23 814 | LET shift, and go to state 24 815 | '(' shift, and go to state 26 816 | 817 | lterm go to state 75 818 | 819 | 820 | state 71 821 | 822 | 27 lterm: F2ARG '(' lterm ',' lterm . ')' 823 | 824 | ')' shift, and go to state 76 825 | 826 | 827 | state 72 828 | 829 | 28 lterm: XFUNCTION '(' ID ')' '(' . lterm ')' 830 | 29 | XFUNCTION '(' ID ')' '(' . lterm ',' lterm ')' 831 | 832 | REC shift, and go to state 13 833 | IF shift, and go to state 15 834 | LAMBDA shift, and go to state 17 835 | ID shift, and go to state 18 836 | NUM shift, and go to state 19 837 | BOOLEAN shift, and go to state 20 838 | F1ARG shift, and go to state 21 839 | F2ARG shift, and go to state 22 840 | XFUNCTION shift, and go to state 23 841 | LET shift, and go to state 24 842 | '(' shift, and go to state 26 843 | 844 | lterm go to state 77 845 | 846 | 847 | state 73 848 | 849 | 31 lterm: LET ID EQ lterm INN . lterm 850 | 851 | REC shift, and go to state 13 852 | IF shift, and go to state 15 853 | LAMBDA shift, and go to state 17 854 | ID shift, and go to state 18 855 | NUM shift, and go to state 19 856 | BOOLEAN shift, and go to state 20 857 | F1ARG shift, and go to state 21 858 | F2ARG shift, and go to state 22 859 | XFUNCTION shift, and go to state 23 860 | LET shift, and go to state 24 861 | '(' shift, and go to state 26 862 | 863 | lterm go to state 78 864 | 865 | 866 | state 74 867 | 868 | 14 stmt: XCALL '(' ID ')' '(' . PATH ')' 869 | 15 | XCALL '(' ID ')' '(' . NUM ')' 870 | 871 | NUM shift, and go to state 79 872 | PATH shift, and go to state 80 873 | 874 | 875 | state 75 876 | 877 | 30 lterm: IF lterm THEN lterm ELSE lterm . 878 | 879 | $default reduce using rule 30 (lterm) 880 | 881 | 882 | state 76 883 | 884 | 27 lterm: F2ARG '(' lterm ',' lterm ')' . 885 | 886 | $default reduce using rule 27 (lterm) 887 | 888 | 889 | state 77 890 | 891 | 28 lterm: XFUNCTION '(' ID ')' '(' lterm . ')' 892 | 29 | XFUNCTION '(' ID ')' '(' lterm . ',' lterm ')' 893 | 894 | ')' shift, and go to state 81 895 | ',' shift, and go to state 82 896 | 897 | 898 | state 78 899 | 900 | 31 lterm: LET ID EQ lterm INN lterm . 901 | 902 | $default reduce using rule 31 (lterm) 903 | 904 | 905 | state 79 906 | 907 | 15 stmt: XCALL '(' ID ')' '(' NUM . ')' 908 | 909 | ')' shift, and go to state 83 910 | 911 | 912 | state 80 913 | 914 | 14 stmt: XCALL '(' ID ')' '(' PATH . ')' 915 | 916 | ')' shift, and go to state 84 917 | 918 | 919 | state 81 920 | 921 | 28 lterm: XFUNCTION '(' ID ')' '(' lterm ')' . 922 | 923 | $default reduce using rule 28 (lterm) 924 | 925 | 926 | state 82 927 | 928 | 29 lterm: XFUNCTION '(' ID ')' '(' lterm ',' . lterm ')' 929 | 930 | REC shift, and go to state 13 931 | IF shift, and go to state 15 932 | LAMBDA shift, and go to state 17 933 | ID shift, and go to state 18 934 | NUM shift, and go to state 19 935 | BOOLEAN shift, and go to state 20 936 | F1ARG shift, and go to state 21 937 | F2ARG shift, and go to state 22 938 | XFUNCTION shift, and go to state 23 939 | LET shift, and go to state 24 940 | '(' shift, and go to state 26 941 | 942 | lterm go to state 85 943 | 944 | 945 | state 83 946 | 947 | 15 stmt: XCALL '(' ID ')' '(' NUM ')' . 948 | 949 | $default reduce using rule 15 (stmt) 950 | 951 | 952 | state 84 953 | 954 | 14 stmt: XCALL '(' ID ')' '(' PATH ')' . 955 | 956 | $default reduce using rule 14 (stmt) 957 | 958 | 959 | state 85 960 | 961 | 29 lterm: XFUNCTION '(' ID ')' '(' lterm ',' lterm . ')' 962 | 963 | ')' shift, and go to state 86 964 | 965 | 966 | state 86 967 | 968 | 29 lterm: XFUNCTION '(' ID ')' '(' lterm ',' lterm ')' . 969 | 970 | $default reduce using rule 29 (lterm) 971 | -------------------------------------------------------------------------------- /parser.tab.h: -------------------------------------------------------------------------------- 1 | /* A Bison parser, made by GNU Bison 3.6.4. */ 2 | 3 | /* Bison interface for Yacc-like parsers in C 4 | 5 | Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, 6 | Inc. 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . */ 20 | 21 | /* As a special exception, you may create a larger work that contains 22 | part or all of the Bison parser skeleton and distribute that work 23 | under terms of your choice, so long as that work isn't itself a 24 | parser generator using the skeleton or a modified version thereof 25 | as a parser skeleton. Alternatively, if you modify or redistribute 26 | the parser skeleton itself, you may (at your option) remove this 27 | special exception, which will cause the skeleton and the resulting 28 | Bison output files to be licensed under the GNU General Public 29 | License without this special exception. 30 | 31 | This special exception was added by the Free Software Foundation in 32 | version 2.2 of Bison. */ 33 | 34 | /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 35 | especially those whose name start with YY_ or yy_. They are 36 | private implementation details that can be changed or removed. */ 37 | 38 | #ifndef YY_YY_PARSER_TAB_H_INCLUDED 39 | # define YY_YY_PARSER_TAB_H_INCLUDED 40 | /* Debug traces. */ 41 | #ifndef YYDEBUG 42 | # define YYDEBUG 0 43 | #endif 44 | #if YYDEBUG 45 | extern int yydebug; 46 | #endif 47 | 48 | /* Token kinds. */ 49 | #ifndef YYTOKENTYPE 50 | # define YYTOKENTYPE 51 | enum yytokentype 52 | { 53 | YYEMPTY = -2, 54 | YYEOF = 0, /* "end of file" */ 55 | YYerror = 256, /* error */ 56 | YYUNDEF = 257, /* "invalid token" */ 57 | HELP = 258, /* HELP */ 58 | TRACEF = 259, /* TRACEF */ 59 | VERBOSEF = 260, /* VERBOSEF */ 60 | USELIB = 261, /* USELIB */ 61 | QUIT = 262, /* QUIT */ 62 | WRITE = 263, /* WRITE */ 63 | SETDIR = 264, /* SETDIR */ 64 | SETLOOPS = 265, /* SETLOOPS */ 65 | SETFIRES = 266, /* SETFIRES */ 66 | STATUS = 267, /* STATUS */ 67 | SYMBOL = 268, /* SYMBOL */ 68 | REC = 269, /* REC */ 69 | DEF = 270, /* DEF */ 70 | IF = 271, /* IF */ 71 | THEN = 272, /* THEN */ 72 | ELSE = 273, /* ELSE */ 73 | GMLGRAPH = 274, /* GMLGRAPH */ 74 | NL = 275, /* NL */ 75 | EQ = 276, /* EQ */ 76 | LAMBDA = 277, /* LAMBDA */ 77 | OP1 = 278, /* OP1 */ 78 | OP2 = 279, /* OP2 */ 79 | ID = 280, /* ID */ 80 | LOP1 = 281, /* LOP1 */ 81 | LOP2 = 282, /* LOP2 */ 82 | NUM = 283, /* NUM */ 83 | BOOLEAN = 284, /* BOOLEAN */ 84 | F1ARG = 285, /* F1ARG */ 85 | F2ARG = 286, /* F2ARG */ 86 | XFUNCTION = 287, /* XFUNCTION */ 87 | LET = 288, /* LET */ 88 | INN = 289, /* INN */ 89 | PATH = 290, /* PATH */ 90 | XCALL = 291 /* XCALL */ 91 | }; 92 | typedef enum yytokentype yytoken_kind_t; 93 | #endif 94 | 95 | /* Value type. */ 96 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 97 | union YYSTYPE 98 | { 99 | #line 60 "parser.y" 100 | 101 | char string[500]; 102 | int number; 103 | int intero; 104 | struct termGraph *grafo; 105 | 106 | #line 107 "parser.tab.h" 107 | 108 | }; 109 | typedef union YYSTYPE YYSTYPE; 110 | # define YYSTYPE_IS_TRIVIAL 1 111 | # define YYSTYPE_IS_DECLARED 1 112 | #endif 113 | 114 | 115 | extern YYSTYPE yylval; 116 | 117 | int yyparse (void); 118 | 119 | #endif /* !YY_YY_PARSER_TAB_H_INCLUDED */ 120 | -------------------------------------------------------------------------------- /parser.y: -------------------------------------------------------------------------------- 1 | /* Grammar for the PELCR language 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | %{ 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #ifdef SOLARIS 27 | #include 28 | #endif 29 | #include 30 | #include 31 | #ifdef MPE_GRAPH 32 | #include 33 | #endif 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | //#include 41 | 42 | //#include "mydefs.h" 43 | //#include "symbolic.h" 44 | //#include "graph.h" 45 | //#include "combustion.h" 46 | //#include "y.tab.h" 47 | //#include "io.h" 48 | //#include "dvm.h" 49 | //#include "distribution.h" 50 | //#include "lambdastar.h" 51 | //#include "buildgraph.h" 52 | #include "var.h" 53 | int npozzi=0; 54 | int yylex(); 55 | int yyerror(char *s); 56 | %} 57 | 58 | 59 | %union { 60 | char string[500]; 61 | int number; 62 | int intero; 63 | struct termGraph *grafo; 64 | }; 65 | 66 | %token HELP TRACEF VERBOSEF USELIB QUIT WRITE SETDIR SETLOOPS SETFIRES STATUS SYMBOL REC DEF IF THEN ELSE GMLGRAPH 67 | %token NL EQ LAMBDA 68 | %token OP1 OP2 ID LOP1 LOP2 NUM BOOLEAN F1ARG F2ARG XFUNCTION LET INN PATH XCALL 69 | 70 | %type lterm 71 | %type stmt 72 | %right EQ 73 | %left OP1 LOP1 74 | %left OP2 LOP2 75 | %right F1ARG 76 | %start lines 77 | 78 | %% 79 | lines : lines line | line ; 80 | line: lterm NL { 81 | varname=0; 82 | /*MostraGrafo($2); 83 | */ 84 | 85 | InitializeIncoming((termGraph *)$1); 86 | DeallocTermGraph($1); 87 | /*MostraTabelle();*/ 88 | 89 | /* 90 | findex=-1; 91 | kindex=-1; 92 | */ 93 | /*Print($2->root,0);*/ 94 | return kindex; 95 | } 96 | | stmt NL { 97 | switch($1) { 98 | 99 | case QUIT: return MAXNUMCOST+1; break; 100 | case SYMBOL: ShowTable(); break; 101 | case TRACEF: { 102 | if (traceflag==1) { 103 | traceflag=0; 104 | printf("\n Trace Mode Off\n "); 105 | } 106 | else 107 | if (traceflag==0) { 108 | traceflag=1; 109 | printf("\n Trace Mode On\n "); 110 | } 111 | }; break; 112 | 113 | case VERBOSEF: { 114 | if (verflag==1) { 115 | verflag=0; 116 | printf("\n Verbose Mode Off\n "); 117 | } 118 | else 119 | if (verflag==0) { 120 | verflag=1; 121 | printf("\n Verbose Mode On\n "); 122 | } 123 | }; break; 124 | }; 125 | printf("\n PELCR 10.0> "); fflush(stdout); 126 | } 127 | | error { 128 | yyerrok; 129 | printf("\n PELCR 10.0 > "); 130 | yyerror(""); 131 | }; 132 | 133 | stmt : QUIT { $$=QUIT; } 134 | | SYMBOL { $$=SYMBOL; } 135 | | TRACEF { $$=TRACEF;} 136 | | VERBOSEF { $$=VERBOSEF;} 137 | | SETLOOPS NUM { 138 | maxloop = atol($2) ; 139 | printf("\n(%d) setting final idle loops to %ld",rank,maxloop); 140 | /* this is not well implemented since parsing is only on rank 0 process 141 | thus PEs with different rank do not receive this value and run with 142 | the default setting of maxloop */ 143 | } 144 | | SETFIRES NUM { 145 | maxfires = atol($2) ; 146 | printf("\n(%d) setting max number of combustion steps to %ld",rank,maxfires); 147 | } 148 | 149 | | WRITE PATH { SetOutputFile($2) ; } 150 | | USELIB PATH { LoadLib($2);} 151 | | XCALL '(' ID ')' '(' PATH ')' { CallXF1ArgChar($3,$6); } 152 | | XCALL '(' ID ')' '(' NUM ')' { CallXF1ArgUser($3,$6); } 153 | | DEF ID EQ lterm { PutSymbol($2,$4); } 154 | | SETDIR PATH { SetDirectory($2) ; } ; 155 | | STATUS { WriteStatus() ; }; 156 | | HELP { WriteHelp() ; }; 157 | | GMLGRAPH { return kindex ;} 158 | 159 | lterm : LAMBDA ID '.' lterm 160 | { 161 | $$=BuildLambda($2,$4); 162 | /* printf("\n\t'astrazione su %s'",$2);*/ 163 | } 164 | | '(' lterm ')' lterm 165 | { 166 | /*lift=0;*/ 167 | $$=BuildApplication($2,$4); 168 | /* printf("\n\t 'applicazione'"); */ 169 | } 170 | | ID 171 | { 172 | termGraph *t; 173 | t=IsThere($1); 174 | if (t) $$=t; 175 | else $$=BuildVar($1); 176 | 177 | /* printf("\n\t 'ID' %s ",$1); */ 178 | } 179 | | NUM 180 | { $$=BuildNumber($1); } 181 | | BOOLEAN 182 | { $$=BuildBool($1);} 183 | | F1ARG '(' lterm ')' 184 | { $$=BuildF1Arg($1,$3);} 185 | | F2ARG '(' lterm ',' lterm ')' 186 | { $$=BuildF2Arg($1,$3,$5);} 187 | | XFUNCTION '(' ID ')' '(' lterm ')' 188 | { $$=BuildXF1Arg($3,$6); } 189 | | XFUNCTION '(' ID ')' '(' lterm ',' lterm ')' 190 | { $$=BuildXF2Arg($3,$6,$8); } 191 | | IF lterm THEN lterm ELSE lterm 192 | { $$=BuildITE($2,$4,$6);} 193 | | LET ID EQ lterm INN lterm 194 | { $$=BuildLet($2,$4,$6);} 195 | | REC ID INN lterm 196 | { $$=BuildRec($2,$4);} 197 | 198 | 199 | %% 200 | /* An optional but friendlier yyerror function... */ 201 | int yyerror(char *s) 202 | { 203 | extern int yylineno; // defined and maintained in lex 204 | extern char *yytext; // defined and maintained in lex 205 | fprintf(stderr, "ERROR: %s at symbol '%s' on line %d\n", s, yytext, yylineno); 206 | return -1; 207 | } 208 | 209 | -------------------------------------------------------------------------------- /pelcrexamples/.gitignore: -------------------------------------------------------------------------------- 1 | /cvs/ 2 | -------------------------------------------------------------------------------- /pelcrexamples/10square.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 4 | ((ten)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/121triple_f.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def fun = \x.xfunction(addone)(x) 3 | #def delta = \x.(x)x 4 | #def two = \f.\x.(f)(f)x 5 | #def eleven = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 6 | 7 | #def pi1 = \a.\b.\c.a 8 | #def pi2 = \a.\b.\c.b 9 | #def pi3 = \a.\b.\c.c 10 | 11 | #def triple = \a.\b.\c.\t.(((t)a)b)c 12 | 13 | #def A = (((triple)1)500)1000 14 | #def F = \z.(((triple)(fun)(z)pi1)(fun)(z)pi2)(fun)(z)pi3 15 | (((two)eleven)F)A 16 | 17 | #quit 18 | 19 | -------------------------------------------------------------------------------- /pelcrexamples/200checksum.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def checksum = \x.xfunction(checksum)(x) 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | ((four)checksum)12345 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/20checksum.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def checksum = \x.xfunction(checksum)(x) 3 | #def twenty = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 4 | ((twenty)checksum)12345 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/20square.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def twenty = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 4 | ((twenty)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/2I.plcr: -------------------------------------------------------------------------------- 1 | (\f.\x.(f)(f)x)\x.x 2 | #quit 3 | -------------------------------------------------------------------------------- /pelcrexamples/2dd4.plcr: -------------------------------------------------------------------------------- 1 | #def delta = \x.(x)x 2 | #def four = \f.\x.(f)(f)(f)(f)x 3 | #def two = \f.\x.(f)(f)x 4 | #def I = \x.x 5 | ((two)(delta)(delta)four)I 6 | #quit 7 | 8 | -------------------------------------------------------------------------------- /pelcrexamples/4checksum.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def checksum = \x.xfunction(checksum)(x) 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | ((four)checksum)12345 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/4product.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def prod = \x.xfunction(product2)(3,x) 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | ((four)prod)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/4square.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | ((four)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/5square.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def five = \f.\x.(f)(f)(f)(f)(f)x 4 | ((five)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/BruteTest.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def double = \l.\k.\x.((l)k)((l)k)x 3 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 4 | #def F1 =\x.xfunction(show)(x) 5 | #def FF = \l.((map)F1)(double)l 6 | #def AA = \k.\x.((k)123)((k)10)((k)3)x 7 | #def two = \f.\x.(f)(f)x 8 | #def four = \f.\x.(f)(f)(f)(f)x 9 | #def five = \f.\x.(f)(f)(f)(f)(f)x 10 | #def six = \f.\x.(f)(f)(f)(f)(f)(f)x 11 | #def seven = \f.\x.(f)(f)(f)(f)(f)(f)(f)x 12 | #def eight = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)x 13 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 14 | 15 | ((eight)FF)AA 16 | #quit 17 | -------------------------------------------------------------------------------- /pelcrexamples/EAL: -------------------------------------------------------------------------------- 1 | graph [ id 1 2 | creator "marco" 3 | directed 1 4 | node [ id 0 ] 5 | node [ id 1 ] 6 | node [ id 2 ] 7 | node [ id 3 ] 8 | node [ id 4 ] 9 | node [ id 5 ] 10 | node [ id 6 ] 11 | 12 | node [ id 7 ] 13 | node [ id 8 ] 14 | node [ id 9 ] 15 | node [ id 10 ] 16 | 17 | edge [ source 1 target 0 label "--+1" ] 18 | edge [ source 1 target 2 label "++-q" ] 19 | 20 | edge [ source 10 target 2 label "+-+pw(2,0)p!1pw(1,0)" ] 21 | edge [ source 10 target 2 label "+++pw(2,0)p!1q" ] 22 | 23 | edge [ source 9 target 2 label "+-+pw(2,0)q" ] 24 | edge [ source 9 target 3 label "+++1" ] 25 | 26 | edge [ source 8 target 3 label "+++!1q" ] 27 | edge [ source 8 target 2 label "+-+qq" ] 28 | 29 | edge [ source 7 target 2 label "+-+pw(3,1)" ] 30 | edge [ source 7 target 3 label "++-!1p" ] 31 | 32 | edge [ source 4 target 2 label "+--ppw(6,2)!1q" ] 33 | edge [ source 4 target 2 label "++-pq" ] 34 | 35 | edge [ source 5 target 2 label "+--ppw(6,2)!1p" ] 36 | edge [ source 5 target 2 label "++-ppw(5,1)!1q" ] 37 | 38 | edge [ source 6 target 2 label "+--ppw(5,1)!1ppw(4,0)" ] 39 | edge [ source 6 target 2 label "++-ppw(5,1)!1pq" ] 40 | 41 | ] 42 | 43 | -------------------------------------------------------------------------------- /pelcrexamples/EAL.gml: -------------------------------------------------------------------------------- 1 | graph [ id 1 2 | creator "marco" 3 | directed 1 4 | node [ id 0 ] 5 | node [ id 1 ] 6 | node [ id 2 ] 7 | node [ id 3 ] 8 | node [ id 4 ] 9 | node [ id 5 ] 10 | node [ id 6 ] 11 | 12 | node [ id 7 ] 13 | node [ id 8 ] 14 | node [ id 9 ] 15 | node [ id 10 ] 16 | 17 | edge [ source 1 target 0 label "--+1" ] 18 | edge [ source 1 target 2 label "++-1q" ] 19 | 20 | edge [ source 10 target 2 label "+-+pw(2,0)p!1pw(1,0)" ] 21 | edge [ source 10 target 2 label "+++pw(2,0)p!1q" ] 22 | 23 | edge [ source 9 target 2 label "+-+pw(2,0)q" ] 24 | edge [ source 9 target 3 label "+++1" ] 25 | 26 | edge [ source 8 target 3 label "+++!1q" ] 27 | edge [ source 8 target 2 label "+-+qq" ] 28 | 29 | edge [ source 7 target 2 label "+-+pw(3,1)" ] 30 | edge [ source 7 target 3 label "++-!1p" ] 31 | 32 | edge [ source 4 target 2 label "+--ppw(6,2)!1q" ] 33 | edge [ source 4 target 2 label "++-pq" ] 34 | 35 | edge [ source 5 target 2 label "+--ppw(6,2)!1p" ] 36 | edge [ source 5 target 2 label "++-ppw(5,1)!1q" ] 37 | 38 | edge [ source 6 target 2 label "+--ppw(5,1)!1ppw(4,0)" ] 39 | edge [ source 6 target 2 label "++-ppw(5,1)!1pq" ] 40 | 41 | ] 42 | 43 | -------------------------------------------------------------------------------- /pelcrexamples/brute_force.plcr: -------------------------------------------------------------------------------- 1 | /* this example shows how to use the C-ffi code 2 | to implement a parallel brute-force executor 3 | of a password cracker */ 4 | 5 | /* note that in PELCR the theory for distributed execution 6 | of ffi has been proved to be correct only for unary 7 | functions (as it is in this particular case) */ 8 | 9 | #include crypto_primitives 10 | 11 | #def join = \l1 .\l2. \k. \x. ((l1)k)((l2)k)x 12 | #def map = \f. \list.\k.\x.((list)\y.(k)(f)y)x 13 | 14 | #def generate_trials = \s. ((join) (oneexpand)s ) (zeroexpand)s 15 | 16 | #def oneexpand = \y. xfunction(shiftplus) y 17 | #def zeroexpand = \y. xfunction(shift) y 18 | 19 | #def test_function = xfunction(test_encoder) 20 | 21 | #def bruteforce = \n.\w. ((map) test_function) ((n)generate_trials) \k.\x.((k) w)x 22 | 23 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 24 | 25 | ((bruteforce)ten) longword(0) 26 | 27 | #quit 28 | -------------------------------------------------------------------------------- /pelcrexamples/brute_force_plcr: -------------------------------------------------------------------------------- 1 | #def join = \l1 .\l2. \k. \x. ((l1)k)((l2)k)x 2 | 3 | #def generate_trials = \s. ((join) (oneexpand)s ) (zeroexpand)s 4 | 5 | #def oneexpand = \y. xfunction(shiftplus) y 6 | #def zeroexpand = \y. xfunction(shift) y 7 | 8 | church(n)(attack) longword(0) 9 | -------------------------------------------------------------------------------- /pelcrexamples/d2.plcr: -------------------------------------------------------------------------------- 1 | #def delta = \x.(x)x 2 | #def two = \f.\x.(f)(f)x 3 | (delta)two 4 | #quit 5 | 6 | -------------------------------------------------------------------------------- /pelcrexamples/d3triple_f.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def fun = \x.xfunction(addone)(x) ; 3 | #def delta = \x.(x)x ; 4 | #def three = \f.\x.(f)(f)(f)x ; 5 | 6 | #def pi1 = \a.\b.\c.a ; 7 | #def pi2 = \a.\b.\c.b ; 8 | #def pi3 = \a.\b.\c.c ; 9 | 10 | #def triple = \a.\b.\c.\t.(((t)a)b)c ; 11 | 12 | #def A = (((triple)1)500)1000 ; 13 | #def F = \z.(((triple)(fun)(z)pi1)(fun)(z)pi2)(fun)(z)pi3 ; 14 | (((delta)three)F)A ; 15 | 16 | #quit 17 | 18 | -------------------------------------------------------------------------------- /pelcrexamples/d4.plcr: -------------------------------------------------------------------------------- 1 | /* esecuzione di delta 4 */ 2 | 3 | #def delta = \x.(x)x ; 4 | #def four = \f.\x.(f)(f)(f)(f)x ; 5 | (delta)four ; 6 | #quit ; 7 | 8 | -------------------------------------------------------------------------------- /pelcrexamples/d4addone.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def sumone = \x.xfunction(addone)(x) 3 | #def delta = \x.(x)x 4 | #def four = \f.\x.(f)(f)(f)(f)x 5 | (((delta)four)sumone)1 6 | #quit 7 | 8 | -------------------------------------------------------------------------------- /pelcrexamples/d4checksum.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def checksum = \x.xfunction(checksum)(x) 3 | #def delta = \x.(x)x 4 | #def four = \f.\x.(f)(f)(f)(f)x 5 | (((delta)four)checksum)12345 6 | #quit 7 | 8 | -------------------------------------------------------------------------------- /pelcrexamples/d4double_f.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def fun = \x.xfunction(addone)(x) 3 | #def delta = \x.(x)x 4 | #def four = \f.\x.(f)(f)(f)(f)x 5 | 6 | #def pi1 = \a.\b.a 7 | #def pi2 = \a.\b.b 8 | 9 | #def double = \a.\b.\t.((t)a)b 10 | 11 | #def A = ((double)1)500 12 | #def F = \z.((double)(fun)(z)pi1)(fun)(z)pi2 13 | (((delta)four)F)A 14 | 15 | #quit 16 | 17 | -------------------------------------------------------------------------------- /pelcrexamples/d4triple_f.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def fun = \x.xfunction(addone)(x) 3 | #def delta = \x.(x)x 4 | #def four = \f.\x.(f)(f)(f)(f)x 5 | 6 | #def pi1 = \a.\b.\c.a 7 | #def pi2 = \a.\b.\c.b 8 | #def pi3 = \a.\b.\c.c 9 | 10 | #def triple = \a.\b.\c.\t.(((t)a)b)c 11 | 12 | #def A = (((triple)1)500)1000 13 | #def F = \z.(((triple)(fun)(z)pi1)(fun)(z)pi2)(fun)(z)pi3 14 | (((delta)four)F)A 15 | 16 | #quit 17 | 18 | -------------------------------------------------------------------------------- /pelcrexamples/dcm2005.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | 3 | #def double = \l.\k.\x.((l)k)((l)k)x 4 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 5 | #def F1 = \x.xfunction(addone)(x) 6 | #def FF = \l.((map)F1)(double)l 7 | #def AA = \k.\x.((k)123)((k)10)((k)3)x 8 | 9 | #def five = \f.\x.(f)(f)(f)(f)(f)x 10 | #def seven = \f.\x.(f)(f)(f)(f)(f)(f)(f)x 11 | #def nine = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)x 12 | ((nine)FF)AA 13 | quit 14 | -------------------------------------------------------------------------------- /pelcrexamples/dd2.plcr: -------------------------------------------------------------------------------- 1 | /* delta delta two: the resulting graph, 2 | representing the Church numeral 256 3 | is verifiable by hand */ 4 | 5 | #def delta = \x.(x)x ; 6 | #def two = \f.\x.(f)(f)x ; 7 | (delta)(delta)two ; 8 | #quit 9 | 10 | -------------------------------------------------------------------------------- /pelcrexamples/dd3.plcr: -------------------------------------------------------------------------------- 1 | #def delta = \x.(x)x ; 2 | #def three = \f.\x.(f)(f)(f)x ; 3 | (delta)(delta)three ; 4 | #quit ; 5 | -------------------------------------------------------------------------------- /pelcrexamples/dd4.gml: -------------------------------------------------------------------------------- 1 | graph [ id 1 2 | creator "lambda2gml" 3 | directed 1 4 | edge [ source 134536336 target 134536337 label "--+1" comment "OUT"] 5 | node [ id 134536336 ] 6 | node [ id 134536337 ] 7 | edge [ source 134536280 target 134536232 label "++-w(1,1)" ] 8 | edge [ source 134536336 target 134536232 label "++-w(0,0)q" ] 9 | edge [ source 134536280 target 134536232 label "+--w(0,0)p" ] 10 | node [ id 134536280 ] 11 | edge [ source 134536520 target 134536232 label "+-+1" ] 12 | node [ id 134536520 ] 13 | node [ id 134536232 ] 14 | edge [ source 134536464 target 134536416 label "++-!1w(1,1)" ] 15 | edge [ source 134536520 target 134536416 label "++-!1w(0,0)q" ] 16 | edge [ source 134536464 target 134536416 label "+--!1w(0,0)p" ] 17 | node [ id 134536464 ] 18 | edge [ source 134536640 target 134536416 label "+++!2pw(3,3)!3q" ] 19 | edge [ source 134536888 target 134536416 label "+++!2pw(3,3)!3p" ] 20 | node [ id 134536888 ] 21 | edge [ source 134536696 target 134536416 label "+++!2pw(2,2)!2q" ] 22 | edge [ source 134536640 target 134536416 label "+-+!2pw(2,2)!2p" ] 23 | node [ id 134536640 ] 24 | edge [ source 134536752 target 134536416 label "+++!2pw(1,1)!1q" ] 25 | edge [ source 134536696 target 134536416 label "+-+!2pw(1,1)!1p" ] 26 | node [ id 134536696 ] 27 | edge [ source 134536808 target 134536416 label "+++!2pw(0,0)q" ] 28 | edge [ source 134536752 target 134536416 label "+-+!2pw(0,0)p" ] 29 | node [ id 134536752 ] 30 | edge [ source 134536888 target 134536416 label "+-+!2qpw(4,4)" ] 31 | edge [ source 134536808 target 134536416 label "+-+!2qq" ] 32 | node [ id 134536808 ] 33 | node [ id 134536416 ] 34 | ] 35 | -------------------------------------------------------------------------------- /pelcrexamples/dd4.plcr: -------------------------------------------------------------------------------- 1 | /* 2 | evaluate a term with a huge normal form 3 | so huge that it would be impossible to 4 | be written (not enogh space in the universe). 5 | */ 6 | #def delta = \x.(x)x ; 7 | #def four = \f.\x.(f)(f)(f)(f)x ; 8 | (delta)(delta)four ; 9 | #quit ; 10 | -------------------------------------------------------------------------------- /pelcrexamples/dd5.plcr: -------------------------------------------------------------------------------- 1 | #def delta = \x.(x)x 2 | #def five = \f.\x.(f)(f)(f)(f)(f)x 3 | (delta)(delta)five 4 | #quit 5 | 6 | -------------------------------------------------------------------------------- /pelcrexamples/difficult.plcr: -------------------------------------------------------------------------------- 1 | #def two = \f.\x.(f)(f)x 2 | #def three = \f.\x.(f)(f)(f)x 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | #def I = \x.x 5 | 6 | 7 | (((((three)two)two)two)I)I 8 | 9 | #quit 10 | 11 | 12 | (((two)two)I)I 13 | ((((two)two)two)I)I // 0 sec. 14 | ((three)I)I 15 | (((three)three)I)I 16 | ((((three)two)two)I)I // 0 sec 17 | (((((two)two)two)two)I)I // 25 sec 18 | (((((two)two)three)two)I)I //explodes 19 | (((((two)two)two)three)I)I // explodes 20 | (((((two)two)three)three)I)I 21 | (((four)four)I)I 22 | (((((two)two)three)two)I)I 23 | -------------------------------------------------------------------------------- /pelcrexamples/doublelist.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def mul = \x.\y.xfunction(product2)(x,y) 3 | #def show = \x.xfunction(show)(x) 4 | #def showB = \x.\y.xfunction(show2)(x,y) 5 | #def suc = \x.xfunction(succ2)(x) 6 | 7 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 8 | #def double_list = \xs.((map)\x.((mul)2)x)xs 9 | 10 | #def AA = \k.\x.((k)123)((k)10)((k)3)x 11 | 12 | (((double_list)AA)\a.\b.(show)(suc)((showB)b)a)0 13 | 14 | #quit 15 | 16 | // l'esecuzione stampa un solo valore: 17 | - per via della condivisione ? 18 | - per errore nel programma funzionale ? 19 | - per errore di PELCR ? 20 | 21 | ++++ 22 | 23 | (0) 3rd barrier ANDIAMO!!!!!!!!!! and WAIT FOR CURSOR 24 | (0) 2 * 10 = 20 25 | (0) 2 * 3 = 6 26 | (0) 2 * 123 = 246 27 | (0) ShowPair (0,6) 28 | (0) Succ(0) 29 | 30 | date : Tue Aug 23 14:48:30 2005 31 | (0) Elapsed time : 0 32 | (0) Nodi Finali : 272 33 | (0) N. di nodi combusti : 643 34 | (0) Fires : 357 35 | (0) families reductions : 20 36 | -------------------------------------------------------------------------------- /pelcrexamples/explosions: -------------------------------------------------------------------------------- 1 | #def I = \x.x 2 | #def two = \f.\x.(f)(f)x 3 | 4 | #def G = \n.((n)(two)I)I 5 | #def F = \n.((n)(two)(two)I)I 6 | 7 | #def one = \f.\x.(f)x 8 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 9 | #def thirteen = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 10 | #def nineteen = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pelcrexamples/extsucc.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def double = \l.\k.\x.((l)k)((l)k)x 3 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 4 | #def F1 =\x.xfunction(addone)(x) 5 | #def FF = \l.((map)F1)(double)l 6 | #def AA = \k.\x.((k)1)((k)23)((k)150)x 7 | #def two = \f.\x.(f)(f)x 8 | #def four = \f.\x.(f)(f)(f)(f)x 9 | #def five = \f.\x.(f)(f)(f)(f)(f)x 10 | #def six = \f.\x.(f)(f)(f)(f)(f)(f)x 11 | #def seven = \f.\x.(f)(f)(f)(f)(f)(f)(f)x 12 | #def eight = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)x 13 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 14 | 15 | ((five)FF)AA 16 | #quit 17 | 18 | -------------------------------------------------------------------------------- /pelcrexamples/fact.plcr: -------------------------------------------------------------------------------- 1 | #def one = \f.\x.(f)x 2 | #def tt = \f.\x.f 3 | #def ff = \f.\x.x 4 | #def isz = \n.((n) \d.tt)ff 5 | #def I = \x.x 6 | #def S = \x.((x)I)\y.\z.((x)y)(y)z 7 | #def K = \x.\y.\z.z 8 | #def pd = \n.( (n) S ) \w.(n) K 9 | #def g=(rec fact in \x.\n.((isz) n)(fact)(pd)n)one)\f.\x.(f)(f)(f)x 10 | #quit 11 | 12 | -------------------------------------------------------------------------------- /pelcrexamples/fibonacci.plcr: -------------------------------------------------------------------------------- 1 | #def pippo = java( 2 | int p(int x) 3 | { 4 | return (2*x) 5 | } 6 | ) 7 | 8 | (\x.add(x,x))(pippo)2 9 | 10 | 11 | #def fst = \u.\v.u 12 | #def snd = \u.\v.v 13 | #def suc = \n.\x.\y.((n)x)(x)y 14 | #def pair = \x.\y.\z.((z)x)y 15 | #def molt = \n.\m.\x.(n)(m)x 16 | #def one = \f.\x.(f)x 17 | #def nextfibo = \p. (\a.(\b. ((pair)((molt)a)b)a)(suc)(p)snd)(p)fst 18 | 19 | #def fiboprim = \n. (((n)nextfibo)((pair)zero)one)fst 20 | (fiboprim)\c.\d.(c)(c)(c)d 21 | #quit 22 | -------------------------------------------------------------------------------- /pelcrexamples/fivesquare.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def five = \f.\x.(f)(f)(f)(f)(f)x 4 | ((five)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/foursquare.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def four = \f.\x.(f)(f)(f)(f)x 4 | ((four)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /pelcrexamples/jfig2.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def pls = \x.\y.xfunction(add2)(x,y) 3 | 4 | (((\x.x)pls)1 )3 5 | #quit 6 | -------------------------------------------------------------------------------- /pelcrexamples/k2i.plcr: -------------------------------------------------------------------------------- 1 | #def kduei = (\x.\y.y)(\f.\g.(f)(f)g)\z.z 2 | #quit -------------------------------------------------------------------------------- /pelcrexamples/kdd.plcr: -------------------------------------------------------------------------------- 1 | #def k=\x.\y.y 2 | #def d=\u.(u)u 3 | let x = d in (k)(x)x 4 | #quit 5 | -------------------------------------------------------------------------------- /pelcrexamples/ki.plcr: -------------------------------------------------------------------------------- 1 | #def kduei = (\x.\y.y)(\f.\g.(f)(f)g)\z.z 2 | kduei 3 | #quit 4 | -------------------------------------------------------------------------------- /pelcrexamples/longid.plcr: -------------------------------------------------------------------------------- 1 | #def delta = \xx. (xx)xx 2 | #def two = \fun. \arg. (fun)(fun)arg 3 | #def scale = \n . \x. Mult(n,x) 4 | #def scale2 = \x. ((scale) 2 )x 5 | 6 | #def empty = \k.\x.x 7 | #def cons = \l.\a.\k.\x.((k)a)((l)k)x 8 | 9 | #def map = \f. \list.\k.\x.((list)\y.(k)(f)y)x 10 | #def concat = \l1.\l2.\k.\x.((l1)k)((l2)k)x 11 | 12 | #def length = \l.((l)\f.\x.add(x,1))0 13 | 14 | #def true = \a.\b.a 15 | #def false = \a.\b.b 16 | 17 | #def pair = \a.\b.\p.((p)a)b 18 | #def fst = \p.(true)p 19 | #def snd = \p.(false)p 20 | 21 | #def head = \l.((l)true)false 22 | #def tail = \l.\k.\x.(first)((l)\a.\p.((pair)((cons)p)(snd)p)a)((pair)x)false 23 | 24 | #def listexample = \k.\x.((k)1)((k)2)((k)3)x 25 | 26 | #def listb = ((cons)((cons)((cons)empty)3)2)1 27 | #def nsucc = \x.add(x,1) 28 | 29 | ((map)nsucc)listb 30 | 31 | 32 | 33 | #def nfact = \x. rec fak in if iszero(x) then 1 else mult(x,(fak)pred(x)) 34 | 35 | 36 | 37 | (nfact)5 38 | 39 | #def isempty = \l. ((l) \x.\y.0) 1 40 | 41 | #def reverse = \lista. rec revaux in 42 | if isempty(lista) 43 | then empty 44 | else ((cons)(revaux)(tail)lista)(head)lista 45 | 46 | 47 | #include square.so 48 | xfunction(square)(4) 49 | 50 | (length)listb 51 | 52 | 53 | #quit 54 | -------------------------------------------------------------------------------- /pelcrexamples/matrix.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def prod = \x.\y.xfunction(product2)(x,y) 3 | #def plus = \x.\y.xfunction(add2)(x,y) 4 | #def show = \x.xfunction(show)(x) 5 | #def tt = \a.\b.a 6 | #def ff = \a.\b.b 7 | #def t1 = \a.\b.\c.a 8 | #def t2 = \a.\b.\c.b 9 | #def t3 = \a.\b.\c.c 10 | #def pair = \a.\b.\p.((p)a)b 11 | #def triple = \a.\b.\c.\p.(((p)a)b)c 12 | 13 | #def showtriple = \t.\p.(((p)(show)(t1)t)(show)(t2)t)(show)(t3)t 14 | 15 | #def fst = \p.(p)tt 16 | #def snd = \p.(p)ff 17 | #def empty = \k.\x.x 18 | #def cons = \l.\a.\k.\x.((k)a)((l)k)x 19 | #def head = \l.((l)tt)ff 20 | #def tail = \l.\k.\x.(t3)((l) \a.\t.(((triple)tt)a)(((t1)t)((k)(t2)t)(t3)t)x ) (((triple)ff)\x.x)\x.x 21 | #def two = \f.\x.(f)(f)x 22 | #def five = \f.\x.(f)(f)(f)(f)x 23 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 24 | #def delta = \x.(x)x 25 | #def v1 = \k.\x.((k)1)((k)2)((k)3)x 26 | #def v2 = \k.\x.((k)11)((k)7)((k)13)x 27 | #def v3 = \k.\x.((k)0)((k)1)((k)2)((k)11)x 28 | #def sumlist = \l.((l) \a.\b.((plus)a)b)0 29 | #def bi = ((pair)2)3 30 | #def dot = \l1.\l2. let step = \x.\y.((pair)(tail)(fst)y)((plus)((prod)(head)(fst)y)x)(snd)y in let base = ((pair)l2)0 in ((l1)step)base 31 | 32 | #def A = (((triple)1)2)3 33 | #def f1 = show 34 | #def f2 = show 35 | #def f3 = show 36 | #def F = \t.(((triple)(f1)(t1)t)(f2)(t2)t)(f3)(t3)t 37 | 38 | #def double = \l.\k.\x.((l)k)((l)k)x 39 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 40 | #def F1 = show 41 | #def FF = \l.((map)F1)(double)l 42 | #def AA = \k.\x.((k)123)((k)10)((k)3)x 43 | 44 | ((five)FF)AA 45 | #quit 46 | 47 | ((Plus)((dot)v1)v2)0 48 | (show)(head)v1 49 | (v1)show 50 | 51 | -------------------------------------------------------------------------------- /pelcrexamples/matrix2.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def mul = \x.\y.xfunction(product2)(x,y) 3 | #def pls = \x.\y.xfunction(add2)(x,y) 4 | #def show = \x.xfunction(show)(x) 5 | #def show2 = \x.\y.xfunction(show2)(x,y) 6 | #def suc = \x.xfunction(succ2)(x) 7 | 8 | #def tt = \a.\b.a 9 | #def ff = \a.\b.b 10 | #def t1 = \t.(t)\a.\b.\c.a 11 | #def t2 = \t.(t)\a.\b.\c.b 12 | #def t3 = \t.(t)\a.\b.\c.c 13 | #def pair = \a.\b.\p.((p)a)b 14 | #def triple = \a.\b.\c.\p.(((p)a)b)c 15 | 16 | #def showtriple = \t.\p.(((p)(show)(t1)t)(show)(t2)t)(show)(t3)t 17 | 18 | #def A = (((triple)1)2)3 19 | #def B = ((pair)1)2 20 | #def fst = \p.(p)tt 21 | #def snd = \p.(p)ff 22 | 23 | #def emptylist = \k.\x.x 24 | #def cons = \l.\a.\k.\x.((l)k)((k)a)x 25 | 26 | #def AA = \k.\x.((k)123)((k)10)((k)3)x 27 | #def BB = \k.\x.((k)10)((k)5)((k)2)x 28 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 29 | #def fold = \f.\e.\l.((l)\a. \b.((f)b)a)e 30 | #def foldr = \f.\e.\l.((l)f)e 31 | #def rev = \l. (((fold) cons) emptylist) l 32 | #def mysum = \l.(((foldr) pls) 0) l 33 | #def length = \l.(((foldr) \a.\b.(suc)b) 0) l 34 | #def showlength = \l.(((foldr) \a.\b.(suc)((show2)b)a) 0) l 35 | #def lazylist = \l.(((foldr) pair ) ff ) l 36 | 37 | #def double_list = \xs.((map)\x.((mul)2)x)xs 38 | 39 | #def dot = \v1.\v2.((v1) \a.\bp. ( (pair) ((pls) ((mul) a) (fst)(snd)bp ) (fst)bp) (snd)(snd)bp ) ((pair)0)(lazylist)v2 40 | 41 | (((double_list)AA)\a.\b.(suc)((show2)b)a)0 // l'esecuzione stampa un solo valore (condivisione ??) 42 | #quit 43 | (show)(fst)((dot)(rev)AA)BB 44 | 45 | 46 | 47 | #quit 48 | (((double_list)AA)\a.\b.(suc)((show2)b)a)0 // l'esecuzione stampa un solo valore (condivisione ??) 49 | #def mysum2 = \l.(((fold) plus) 0) l // non funziona ! scoprire perche' 50 | (show)(length)((cons)AA)5 51 | ((map)show)(rev)AA 52 | (show)(fst)(snd)(snd)(lazylist)AA 53 | (show)(fst)((dot)AA)(rev)AA 54 | #def dot = \v1.\v2.((v1) \a.\bp. ( (pair) ((pls)((mul)a)(fst)(snd)bp )(fst)bp) (snd)(snd)bp ) ((pair)0)(lazylist)v2 55 | 56 | 57 | #quit 58 | ((map)\y.((plus)2)y)AA 59 | #def empty = ff 60 | #def cons = \l.\a.((pair)a)l 61 | #def head = \l.(fst)l 62 | #def tail = \l.(snd)l 63 | 64 | #def two = \f.\x.(f)(f)x 65 | #def five = \f.\x.(f)(f)(f)(f)x 66 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 67 | #def delta = \x.(x)x 68 | #def v1 = ((cons)((cons)((cons)empty)1)2)3 69 | #def v2 = ((cons)((cons)((cons)empty)7)11)13 70 | #def v3 = ((cons)((cons)((cons)((cons)empty)0)1)2)11 71 | #def sumlist = \l.((l) \a.\b.((plus)a)b)0 72 | #def bi = ((pair)2)3 73 | #def dot = \l1.\l2. let step = \x.\y.((pair)(tail)(fst)y)((plus)((prod)(head)(fst)y)x)(snd)y in let base = ((pair)l2)0 in ((l1)step)base 74 | 75 | 76 | #def f1 = show 77 | #def f2 = show 78 | #def f3 = show 79 | #def F = \t.(((triple)(f1)(t1)t)(f2)(t2)t)(f3)(t3)t 80 | 81 | #def double = \l.\k.\x.((l)k)((l)k)x 82 | 83 | #def F1 = show 84 | #def FF = \l.((map)F1)(double)l 85 | 86 | 87 | ((five)FF)AA 88 | #quit 89 | 90 | ((Plus)((dot)v1)v2)0 91 | (show)(head)v1 92 | (v1)show 93 | 94 | -------------------------------------------------------------------------------- /pelcrexamples/matrixnew.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def prod = \x.\y.xfunction(product2)(x,y) 3 | #def plus = \x.\y.xfunction(add2)(x,y) 4 | #def show = \x.xfunction(show)(x) 5 | #def tt = \a.\b.a 6 | #def ff = \a.\b.b 7 | #def t1 = \a.\b.\c.a 8 | #def t2 = \a.\b.\c.b 9 | #def t3 = \a.\b.\c.c 10 | #def pair = \a.\b.\p.((p)a)b 11 | #def triple = \a.\b.\c.\p.(((p)a)b)c 12 | #def showtriple = \t.\p.((((p)(show)(t1)t)(show)(t2)t)(show)(t3)t 13 | #def fst = \p.(p)tt 14 | #def snd = \p.(p)ff 15 | #def empty = \k.\x.x 16 | #def cons = \l.\a.\k.\x.((k)a)((l)k)x 17 | #def head = \l.((l)tt)ff 18 | #def tail = \l.\k.\x.(t3)((l) \a.\t.(((triple)tt)a)(((t1)t)((k)(t2)t)(t3)t)x ) (((triple)ff)\x.x)\x.x 19 | #def v1 = \k.\x.((k)1)((k)2)((k)3)x 20 | #def v2 = \k.\x.((k)11)((k)7)((k)13)x 21 | #def v3 = \k.\x.((k)0)((k)1)((k)2)((k)11)x 22 | #def sumlist = \l.((l) \a.\b.((plus)a)b)0 23 | #def bi = ((pair)2)3 24 | #def dot = \l1.\l2. let step = \x.\y.((pair)(tail)(fst)y)((plus)((prod)(head)(fst)y)x)(snd)y in let base = ((pair)l2)0 in ((l1)step)base 25 | 26 | #def A = (((triple)1)2)3 27 | 28 | #quit 29 | 30 | ((plus)((dot)v1)v2)0 31 | (show)(head)v1 32 | (v1)show 33 | 34 | -------------------------------------------------------------------------------- /pelcrexamples/pure.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def double = \l.\k.\x.((l)k)((l)k)x 3 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 4 | #def FF = \l.((map)\x.xfunction(show)(x))(double)l 5 | #def AA = \k.\x.((k)1)((k)23)((k)150)x 6 | #def two = \f.\x.(f)(f)x 7 | #def four = \f.\x.(f)(f)(f)(f)x 8 | #def five = \f.\x.(f)(f)(f)(f)(f)x 9 | #def six = \f.\x.(f)(f)(f)(f)(f)(f)x 10 | #def seven = \f.\x.(f)(f)(f)(f)(f)(f)(f)x 11 | #def eight = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)x 12 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 13 | 14 | ((five)FF)AA 15 | #quit 16 | -------------------------------------------------------------------------------- /pelcrexamples/s0.plcr: -------------------------------------------------------------------------------- 1 | #trace 2 | #verbose 3 | #include "./shared.so" 4 | #def FF = \x.xfunction(square)(x) 5 | #def AA = 4 6 | 7 | (FF)AA 8 | #quit 9 | -------------------------------------------------------------------------------- /pelcrexamples/s1.plcr: -------------------------------------------------------------------------------- 1 | #include "./shared.so" 2 | #def bilist = \y1.\y2.\z1.\z2.\k.\x.((k)(y1)z1)((k)(y2)z2)x 3 | #def FF = \x.xfunction(square)(x) 4 | #def AA = 4 5 | 6 | ((\f.\z.(f)z)FF)AA 7 | #quit 8 | -------------------------------------------------------------------------------- /pelcrexamples/scan.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./numeric.so" 2 | #def tt = \x.\y.x 3 | #def ff = \x.\y.y 4 | def scan = \f.\l.\k.\x.let base = \p.((p)0)x in let step = \y.\z.\p.(\w.((p)w)((k)w)(ff)z)((f)y)(tt)z in ((l)step)base 5 | #def v1 = \k.\x.((k)1)((k)6)((k)2)((k)7)((k)3)((k)4)x 6 | ((scan)\x.\y.xfunction(max)(x,y))v1 7 | #quit 8 | 9 | -------------------------------------------------------------------------------- /pelcrexamples/sharedfunccalls.plcr: -------------------------------------------------------------------------------- 1 | #include "./shared.so" 2 | #def bilist = \y1.\y2.\z1.\z2.\k.\x.((k)(y1)z1)((k)(y2)z2)x 3 | #def FF = \x.xfunction(square)(x) 4 | #def AA = 4 5 | 6 | ((\f.\z.((((bilist)f)f)z)z)FF)AA 7 | #quit 8 | -------------------------------------------------------------------------------- /pelcrexamples/succ.plcr: -------------------------------------------------------------------------------- 1 | #def double = \l.\k.\x.((l)k)((l)k)x 2 | #def map = \f.\l.\k.\x.((l)\y.(k)(f)y)x 3 | #def F1 =\x.succ(x) 4 | #def FF = \l.((map)F1)(double)l 5 | #def AA = \k.\x.((k)1)((k)23)((k)150)x 6 | #def two = \f.\x.(f)(f)x 7 | #def four = \f.\x.(f)(f)(f)(f)x 8 | #def five = \f.\x.(f)(f)(f)(f)(f)x 9 | #def six = \f.\x.(f)(f)(f)(f)(f)(f)x 10 | #def seven = \f.\x.(f)(f)(f)(f)(f)(f)(f)x 11 | #def eight = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)x 12 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 13 | 14 | ((five)FF)AA 15 | #quit 16 | (\x.succ(x))10 17 | 18 | -------------------------------------------------------------------------------- /pelcrexamples/tensquare.plcr: -------------------------------------------------------------------------------- 1 | #uselib "./shared.so" 2 | #def square = \x.xfunction(square)(x) 3 | #def ten = \f.\x.(f)(f)(f)(f)(f)(f)(f)(f)(f)(f)x 4 | ((ten)square)2 5 | #quit 6 | 7 | -------------------------------------------------------------------------------- /print.c: -------------------------------------------------------------------------------- 1 | /* Manager of global address space of memory for graph distributed allocation 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #ifdef SOLARIS 28 | #include 29 | #endif 30 | #include 31 | #include 32 | #include 33 | #ifdef MPE_GRAPH 34 | #include 35 | #endif 36 | #include 37 | #include "var.h" 38 | #include 39 | 40 | static edge*e; 41 | struct messaggio m; 42 | 43 | void writelabel(wstream,e) 44 | FILE *wstream; 45 | edge *e; 46 | { 47 | char symboliclabel[MAXLENWEIGHT]; 48 | char PrintWeight[2*MAXLENWEIGHT]; 49 | char *CurrentWeight = NULL; 50 | char *NewWeight = NULL; 51 | char *CopyWeight = NULL; 52 | int Index=0, Type=0; 53 | 54 | #ifdef _DEBUG 55 | DEBUG_PRINT { 56 | fprintf(logfile,"(%d) SHOW label in writelabel \n",rank); 57 | ShowEdge(e); 58 | } 59 | #endif 60 | 61 | memset(symboliclabel, 0, MAXLENWEIGHT); 62 | memset(PrintWeight, 0, 2*MAXLENWEIGHT); 63 | 64 | CopyWeight = strdup(e->weight); /*allocates sufficient memory for a copy of the 65 | weight, does the copy, and returns a pointer to it*/ 66 | 67 | CurrentWeight = CopyWeight; 68 | 69 | NewWeight = strstr(CurrentWeight,"X("); 70 | 71 | /* ANTO 72 | printf("PW>%s\n",PrintWeight); 73 | printf("CW>%s\n",CopyWeight); 74 | */ 75 | 76 | while(NewWeight != NULL) 77 | { 78 | strncat(PrintWeight, CurrentWeight, NewWeight-CurrentWeight); 79 | 80 | Type = atoi(&NewWeight[2]); 81 | NewWeight = strstr(NewWeight,","); 82 | Index = atoi(&NewWeight[1]); 83 | NewWeight = strstr(NewWeight,")"); 84 | 85 | switch (Type) 86 | { 87 | /* TYPE */ 88 | case 1: 89 | if(Index) 90 | sprintf(symboliclabel," NATout"); 91 | else 92 | sprintf(symboliclabel," NATin"); 93 | break; 94 | 95 | /* KONST */ 96 | case 2: 97 | sprintf(symboliclabel," (%lld)",k[Index][1]); 98 | break; 99 | 100 | /* FUNC */ 101 | case 3: 102 | sprintf(symboliclabel," %s",f_db[f[Index].fun_id].name); 103 | break; 104 | 105 | /* SYNC */ 106 | case 4: 107 | sprintf(symboliclabel," SYNC(%d)",Index); 108 | break; 109 | 110 | /* ARG */ 111 | case 5: 112 | sprintf(symboliclabel," ARG(%d)",Index); 113 | break; 114 | 115 | /* ITE */ 116 | case 6: 117 | sprintf(symboliclabel," ITE(%d)",Index); 118 | break; 119 | 120 | /* ARGLAST */ 121 | case 7: 122 | sprintf(symboliclabel," ARG(%d)",Index); 123 | break; 124 | 125 | default: 126 | break; 127 | }; 128 | strcat(PrintWeight, symboliclabel); 129 | CurrentWeight = (char *) &NewWeight[1]; 130 | NewWeight = strstr(CurrentWeight,"X("); 131 | }; 132 | 133 | strcat(PrintWeight, CurrentWeight); 134 | 135 | /* ANTO 136 | printf("PW Result>%s\n",PrintWeight); 137 | printf("CW Result>%s\n",CopyWeight); 138 | */ 139 | 140 | fprintf(wstream,"label \"%s\" ]\n",PrintWeight); 141 | free(CopyWeight); 142 | return; 143 | } 144 | 145 | void writenode(wstream,p) 146 | FILE *wstream; 147 | node *p; 148 | { 149 | #ifdef _DEBUG 150 | DEBUG_PRINT { fprintf(logfile,"(%d) WRITENODE (function writenode) %p\n",rank,(void*)p);} 151 | #endif 152 | fprintf(wstream,"node [ id %ld label \"%p\" ",((long)p),(void*)p); 153 | fprintf(wstream,"graphics [ w 6.0 h 6.0 type \"oval\" "); 154 | if((p->left.length==0)&&(p->right.length==0)) 155 | { 156 | fprintf(wstream," fill \"#FFFF%dF\" outline \"#000000\" ]] \n",rank); 157 | } 158 | else 159 | if(((p->left.length==1)&&(p->left.eot==1))&&((p->right.length==1)&&(p->right.eot==1))) 160 | { 161 | fprintf(wstream," fill \"#F%d0000\" outline \"#000000\" ]] \n",rank); 162 | } 163 | else 164 | fprintf(wstream," fill \"#AAAA00\" outline \"#000000\" ]] \n"); 165 | 166 | // DEBUG_PRINT { printf("(%d) in writenode pflag = %d\n",rank,pflag); } 167 | p->printed=pflag ; 168 | // DEBUG_PRINT { printf("(%d) in writenode printed = %d\n",rank,p->printed); } 169 | 170 | return; 171 | } 172 | 173 | void writedge(wstream,e,p,c) 174 | FILE *wstream; 175 | edge *e; 176 | node *p; 177 | int c; 178 | { 179 | #ifdef _DEBUG 180 | DEBUG_PRINT { 181 | fprintf(logfile,"(%d) SHOW edge in writedge\n",rank); 182 | ShowEdge(e); 183 | } 184 | #endif 185 | if (p->printed!= pflag) { printf("(%d) ERROR TARGET NODE NOT YET PRINTED \n",rank); } 186 | 187 | #ifdef _DEBUG 188 | DEBUG_PRINT { 189 | fprintf(logfile,"(%d) WRITENODE (function writedge) %p\n",rank,(void*)e->source); 190 | } 191 | #endif 192 | if (e->rankpuit==rank) 193 | { 194 | node *pp ; 195 | pp = BookedAddress(e->creator,(long)e->source); 196 | if (pp->printed != pflag) writenode(wstream,pp); 197 | } 198 | else 199 | writenode(wstream, e->source); 200 | 201 | 202 | /* 203 | fprintf(wstream,"node [ id %d ] \n ",((int)e->source)*size+e->rankpuit); 204 | */ 205 | fprintf(wstream,"edge [ source "); 206 | 207 | if (e->rankpuit==rank) 208 | fprintf(wstream,"%ld ",(long)BookedAddress(e->creator,(long)e->source)); 209 | else 210 | fprintf(wstream,"%ld ",(long)e->source); 211 | 212 | fprintf(wstream,"target %ld ",(long)p); 213 | switch (c) 214 | { 215 | case 0 : { fprintf(wstream," graphics [ fill \"#aa0000\" ") ;} break; 216 | case 1 : { fprintf(wstream," graphics [ fill \"#0000aa\" ") ;} break; 217 | /* case 2 : { fprintf(wstream," graphics [ fill \"#00aa00\" ] \n") ;} break;*/ 218 | default : { 219 | float col; 220 | col =255-255*(float)(c-2)/(float)MINPRIORITY; 221 | printf("-----> %2.2x %d \n",(int)col,(int)col); 222 | fprintf(wstream," graphics [ fill \"#00%2.2x00\" ",(int)col) ;} break ; 223 | } 224 | fprintf(wstream,"targetArrow \"standard\" ] "); 225 | writelabel(wstream,e); 226 | return; 227 | } 228 | 229 | /* 230 | This function makes a dump of an edge encapsulated in a 231 | message in the incoming buffer into the opened stream 232 | wstream, in gml format. 233 | */ 234 | 235 | void mmwrite(wstream, mm, priority) 236 | FILE *wstream; 237 | struct messaggio *mm; 238 | int priority; 239 | { 240 | e=(edge*)InitReference((edge*)e); 241 | /*do nothing */ 242 | /* step 1 : ask for the local address of the virtual edge */ 243 | /* this implies an early creation of the node (before an incoming edge is combusted again this node) */ 244 | 245 | switch(mm->tpy) 246 | { 247 | case EOT_TAG: 248 | { 249 | printf("EOT \n"); 250 | } 251 | break ; 252 | 253 | case ADD_TAG: 254 | { 255 | node *target; 256 | node *source; 257 | 258 | printf("ADD %ld\n",bip3); 259 | target = BookedAddress((mm->vtarget).creator, (long) (mm->vtarget).source); 260 | source = BookedAddress((mm->vsource).creator, (long) (mm->vsource).source); 261 | 262 | if (target->printed != pflag) { 263 | #ifdef _DEBUG 264 | DEBUG_PRINT { fprintf(logfile,"(%d) WRITENODE (function mmwrite) %p\n",rank,(void*)target);} 265 | #endif 266 | writenode(wstream, target); 267 | } 268 | 269 | e->source = source; 270 | sprintf(e->weight,"%s", mm->weight); 271 | e->rankpuit = (mm->vsource).rankpuit; 272 | e->sto = (mm->vsource).sto; 273 | 274 | 275 | #ifdef _DEBUG 276 | DEBUG_PRINT { 277 | fprintf(logfile,"(%d) SHOW edge before entering writedge\n",rank); 278 | ShowEdge(e); 279 | } 280 | #endif 281 | writedge(wstream, e, target,2+priority); 282 | } 283 | break; 284 | } 285 | 286 | /* 287 | if(mm->vtarget.creator!=rank) 288 | { 289 | target= (node*)BookedAddress(mm->vtarget.creator,(int)mm->vtarget.source); 290 | DEBUG_PRINT fprintf(logfile,"(%d) ADDR TARGET BY HASHING [%p]\n",rank,target); 291 | } 292 | else 293 | { 294 | target= mm->vtarget.source; 295 | DEBUG_PRINT fprintf(logfile,"(%d) ADDR TARGET BY REFERENCE [%p]\n",rank,target); 296 | }; 297 | 298 | */ 299 | return ; 300 | } 301 | 302 | int write_buffer(wstream, b, priority) 303 | FILE *wstream; 304 | struct mbuffer *b; 305 | int priority; 306 | { 307 | int i; 308 | #ifdef _DEBUG 309 | DEBUG_PRINT { 310 | fprintf(logfile,"(%d) dumping message buffer in write_buffer\n",rank); 311 | } 312 | #endif 313 | BDump(b) ; 314 | i=b->first; 315 | while(i!=b->last) { 316 | memcpy(&m,&(b->stack[i]),sizeof(struct messaggio)); 317 | ShowMessage(&m); 318 | mmwrite(wstream,&m,priority); 319 | i=(i+1)%MAXPENDING; 320 | } 321 | 322 | i=(b->last - b->first); 323 | if (i<0) i=MAXPENDING+i; 324 | 325 | return i; 326 | } 327 | 328 | void Print(graph g, struct mbuffer *b, long sq) 329 | { 330 | node*P; 331 | edge*e; 332 | int i; 333 | char name[MAXNAMELEN]; 334 | 335 | pflag = !pflag ; 336 | if (sq==1000000) pflag=-1; 337 | #ifdef _DEBUG 338 | DEBUG_PRINT { 339 | printf("(%d) sq = %ld -- pflag = %d\n",rank,sq,pflag); 340 | } 341 | #endif 342 | sprintf(name,"%s%5d%5ld%3ld.gml",outfile,rank,loops,sq); 343 | if((writefile= fopen(name,"w"))==NULL) 344 | { 345 | fprintf(logfile,"Error opening output file\n"); 346 | outflag= 0; 347 | fclose(writefile); 348 | }; 349 | 350 | if((rank==0)&&(outflag)) 351 | { 352 | fprintf(writefile,"graph [ id %ld directed 1 label \"\n Input File: %s \n ",loops,infile); 353 | fprintf(writefile,"Iteration n.%ld\n Successfull Compositions:%ld\n\"\n",loops,bip3); 354 | } 355 | 356 | 357 | /* 358 | Printing all the nodes 359 | */ 360 | 361 | /* Scan the hot part of the graph */ 362 | P= g.hot; 363 | for(i= 0;P!=NULL;i++) 364 | { 365 | // DEBUG_PRINT { printf("(%d) WRITENODE (function Print) node print flag : %d\n",rank,P->printed); } 366 | if (pflag!=P->printed) 367 | { 368 | #ifdef _DEBUG 369 | DEBUG_PRINT 370 | fprintf(logfile,"(%d) WRITENODE (function Print) %p\n",rank,(void*)P); 371 | #endif 372 | writenode(writefile,P); 373 | } 374 | // DEBUG_PRINT { printf("(%d) WRITENODE (function Print) node print flag (after writenode) : %d\n",rank,P->printed);} 375 | P= P->nextpuit; 376 | // DEBUG_PRINT { if (P!=NULL) printf("(%d) WRITENODE (function Print) node print flag (after writenode) : %d\n",rank,P->printed);} 377 | }; 378 | 379 | fflush(writefile); 380 | 381 | /* Scan the cold part of the graph */ 382 | P= g.cold; 383 | for(i= 0;P!=NULL;i++) 384 | { 385 | #ifdef _DEBUG 386 | DEBUG_PRINT { 387 | fprintf(logfile,"(%d) WRITENODE (function Print) %p\n",rank,(void*)P); 388 | }; 389 | #endif 390 | // printf("-------->file pointer [%p]\n",writefile); 391 | writenode(writefile,P); 392 | 393 | P= P->nextpuit; 394 | }; 395 | 396 | /* 397 | Printing all the edges 398 | */ 399 | 400 | /* Rescan the hot part of the graph */ 401 | P = g.hot; 402 | for(i= 0;P!=NULL;i++) 403 | { 404 | e = P->left.vector; 405 | for(;e!=NULL;e= e->vector) 406 | { 407 | #ifdef _DEBUG 408 | DEBUG_PRINT { 409 | fprintf(logfile,"(%d) SHOW edge in LEFT scan-hot-graph before entering writedge\n",rank); 410 | ShowEdge(e); 411 | }; 412 | #endif 413 | 414 | writedge(writefile,e,P,0); 415 | }; 416 | 417 | e= P->right.vector; 418 | for(;e!=NULL;e= e->vector) 419 | { 420 | #ifdef _DEBUG 421 | DEBUG_PRINT { 422 | fprintf(logfile,"(%d) SHOW edge in RIGHT scan-hot-graph before entering writedge\n",rank); 423 | ShowEdge(e); 424 | }; 425 | #endif 426 | writedge(writefile,e,P,1); 427 | }; 428 | 429 | P= P->nextpuit; 430 | }; 431 | 432 | nhot= i; 433 | 434 | fflush(writefile); 435 | 436 | /* Rescan the cold part of the graph */ 437 | P= g.cold; 438 | for(i= 0;P!=NULL;i++) 439 | { 440 | e = P->left.vector; 441 | for(;e!=NULL;e= e->vector) 442 | { 443 | #ifdef _DEBUG 444 | DEBUG_PRINT { 445 | fprintf(logfile,"(%d) SHOW edge in LEFT scan-cold-graph before entering writedge\n",rank); 446 | ShowEdge(e); 447 | } 448 | #endif 449 | writedge(writefile,e,P,0); 450 | }; 451 | 452 | e= P->right.vector; 453 | for(;e!=NULL;e= e->vector) 454 | { 455 | #ifdef _DEBUG 456 | DEBUG_PRINT { 457 | fprintf(logfile,"(%d) SHOW edge in RIGHT scan-cold-graph before entering writedge\n",rank); 458 | ShowEdge(e); 459 | } 460 | #endif 461 | writedge(writefile,e,P,1); 462 | }; 463 | 464 | P= P->nextpuit; 465 | }; 466 | 467 | ncold= i; 468 | /* before to exit we have to scan the incoming buffer to print all the edges waiting to be 469 | processed */ 470 | 471 | 472 | /* at this point we put the same while-do-cycle as in the buffer dump 473 | but here, for each message in the buffer, we call the write message 474 | function */ 475 | 476 | #ifdef _DEBUG 477 | DEBUG_PRINT fprintf(logfile,"(%d) dumping message buffer in Print\n",rank); 478 | #endif 479 | for(i=0;ileft.length); 530 | OUTPUT2 printf("%d incident right edge(s)",P->right.length); 531 | OUTPUT2 printf("and EOT state %d.\n",P->left.eot); 532 | OUTPUTFILE{ 533 | writenode(writefile,P); 534 | e = P->left.vector; 535 | #ifdef _DEBUG 536 | #ifdef MEMDEBUG 537 | fprintf(logfile,"(%d) LEFT EDGES([%p]): ",rank,P); 538 | #endif 539 | #endif 540 | for(;e!=NULL;e= e->vector) 541 | { 542 | #ifdef _DEBUG 543 | #ifdef MEMDEBUG 544 | fprintf(logfile,"%s ",e->weight); 545 | #endif 546 | #endif 547 | writedge(writefile,e,P,0); 548 | }; 549 | #ifdef _DEBUG 550 | #ifdef MEMDEBUG 551 | fprintf(logfile,"\n"); 552 | #endif 553 | #endif 554 | e= P->right.vector; 555 | 556 | #ifdef _DEBUG 557 | #ifdef MEMDEBUG 558 | fprintf(logfile,"(%d) RIGHT EDGES([%p]): ",rank,P); 559 | #endif 560 | #endif 561 | for(;e!=NULL;e= e->vector) 562 | { 563 | #ifdef _DEBUG 564 | #ifdef MEMDEBUG 565 | fprintf(logfile,"%s ",e->weight); 566 | #endif 567 | #endif 568 | writedge(writefile,e,P,1); 569 | }; 570 | #ifdef _DEBUG 571 | #ifdef MEMDEBUG 572 | fprintf(logfile,"\n"); 573 | #endif 574 | #endif 575 | }; 576 | 577 | P= P->nextpuit; 578 | }; 579 | 580 | OUTPUT printf("{%d} Hot Nodes: %d\n",rank,i); 581 | nhot= i; 582 | fflush(writefile); 583 | P= G.cold; 584 | for(i= 0;P!=NULL;i++) 585 | { 586 | OUTPUT2 printf("{%d} environment node n.%d [%p] has ",rank,i,(void*)P); 587 | OUTPUT2 printf("%d incident edge(s) and EOT state %d.\n",P->left.length,P->left.eot); 588 | OUTPUTFILE{ 589 | fprintf(writefile,"node [ id %ld ",((long)P)*size+rank); 590 | fprintf(writefile,"graphics [ w 6.0 h 6.0 type \"oval\" "); 591 | if(P->left.length==0) 592 | {fprintf(writefile," fill \"#FFFFFF\" outline \"#FF0000\" ]]");} 593 | else 594 | fprintf(writefile," fill \"#FF0000\" outline \"#FF0000\" ]]"); 595 | e= P->left.vector; 596 | for(;e!=NULL;e= e->vector) 597 | { 598 | fprintf(writefile,"edge [ source %ld ",((long)e->source)*size+e->rankpuit); 599 | fprintf(writefile,"target %ld ",((long)P)*size+rank); 600 | fprintf(writefile,"label \"%s\" graphics [ fill \"#FF0000\"] ]\n",e->weight); 601 | }; 602 | e= P->right.vector; 603 | for(;e!=NULL;e= e->vector) 604 | { 605 | fprintf(writefile,"edge [ source %ld ",((long)e->source)*size+e->rankpuit); 606 | fprintf(writefile,"target %ld \n",((long)P)*size+rank); 607 | fprintf(writefile,"label \"%s\" graphics [ fill \"#FF0000\"] ]\n",e->weight); 608 | }; 609 | }; 610 | #ifdef _DEBUG 611 | DEBUG_PRINT { 612 | fprintf(logfile,"(%d) COLDLIST-NEXTPRINT([%p]) -> [%p]\n",rank,(void*)P,(void*)P->nextpuit); 613 | fflush(logfile); 614 | } 615 | #endif 616 | P= P->nextpuit; 617 | }; 618 | 619 | P= g.cold; 620 | for(i= 0;P!=NULL;i++)P= P->nextpuit; 621 | OUTPUT printf("{%d} Cold nodes: %d\n",rank,i); 622 | ncold= i; 623 | OUTPUTFILE if(rank==(size-1))fprintf(writefile,"]\n\n"); 624 | if(outflag==1) 625 | { 626 | fclose(writefile); 627 | } 628 | } 629 | -------------------------------------------------------------------------------- /read_back.c: -------------------------------------------------------------------------------- 1 | /* Read-back functions 2 | 3 | Copyright (C) 1997-2015 Marco Pedicini 4 | 5 | This file is part of PELCR. 6 | 7 | PELCR is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | PELCR is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with PELCR. If not, see . */ 19 | #include 20 | #include 21 | //#include 22 | // 23 | //#include "mydefs.h" 24 | //#include "symbolic.h" 25 | //#include "graph.h" 26 | //#include "combustion.h" 27 | ////#include "parser.h" 28 | //#include "io.h" 29 | //#include "dvm.h" 30 | //#include "distribution.h" 31 | //#include "lambdastar.h" 32 | //#include "buildgraph.h" 33 | #include "var.h" 34 | 35 | /* read_back from a virtual net in normal form to a 36 | lambda term */ 37 | 38 | 39 | 40 | 41 | void read_back( node *principal ) 42 | { 43 | // DEBUG{ 44 | 45 | printf("(%d) ********** principal port address %p\n" , rank, (void*)principal); 46 | 47 | // }; 48 | } 49 | -------------------------------------------------------------------------------- /shared.c: -------------------------------------------------------------------------------- 1 | /* This is an external function added as a library, when we want to include 2 | a function to be executed as a side effect on a state 3 | of the machine we can program it in C and compile as a library 4 | to be linked to our executable. 5 | 6 | Copyright (C) 1997-2015 Marco Pedicini 7 | 8 | This file is part of PELCR. 9 | 10 | PELCR is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | PELCR is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with PELCR. If not, see . */ 22 | 23 | #include 24 | extern int rank; 25 | 26 | USERTYPE CRCTable[] = 27 | { 28 | 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 29 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 30 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 31 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 32 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 33 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 34 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 35 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 36 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 37 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 38 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 39 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 40 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 41 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 42 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 43 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 44 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 45 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 46 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 47 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 48 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 49 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 50 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 51 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 52 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 53 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 54 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 55 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 56 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 57 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 58 | 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 59 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 60 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 61 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 62 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 63 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 64 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 65 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 66 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 67 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 68 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 69 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 70 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 71 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 72 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 73 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 74 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 75 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 76 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 77 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 78 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 79 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 80 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 81 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 82 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 83 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 84 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 85 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 86 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 87 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 88 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 89 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 90 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 91 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 92 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 93 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 94 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 95 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 96 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 97 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 98 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 99 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 100 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 101 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 102 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 103 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 104 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 105 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 106 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 107 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 108 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 109 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 110 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 111 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 112 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 113 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 114 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 115 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 116 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 117 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 118 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 119 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 120 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 121 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 122 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 123 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 124 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 125 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 126 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 127 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 128 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 129 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 130 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 131 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 132 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 133 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 134 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 135 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 136 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 137 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 138 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 139 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 140 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 141 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 142 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 143 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 144 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 145 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 146 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 147 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 148 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 149 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 150 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 151 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 152 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 153 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 154 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 155 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 156 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 157 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 158 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 159 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 160 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 161 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 162 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 163 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 164 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 165 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 166 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 167 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 168 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 169 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 170 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 171 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 172 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 173 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 174 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 175 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 176 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 177 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 178 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 179 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 180 | 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 181 | 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 182 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 183 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 184 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 185 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 186 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 187 | 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 188 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 189 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 190 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 191 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 192 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 193 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 194 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 195 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 196 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 197 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 198 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 199 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 200 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 201 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 202 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 203 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 204 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 205 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 206 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 207 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 208 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 209 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 210 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 211 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 212 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 213 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 214 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 215 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 216 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 217 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 218 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 219 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 220 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 221 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 222 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 223 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 224 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 225 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 226 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 227 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 228 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 229 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 230 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 231 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 232 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 233 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 234 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 235 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 236 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 237 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 238 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 239 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 240 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 241 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 242 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 243 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 244 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 245 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 246 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 247 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 248 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 249 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 250 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 251 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 252 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 253 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 254 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 255 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 256 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 257 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 258 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 259 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 260 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 261 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 262 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 263 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 264 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 265 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 266 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 267 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 268 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 269 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 270 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 271 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 272 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 273 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 274 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 275 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 276 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 277 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 278 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 279 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 280 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 281 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 282 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 283 | 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 284 | 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 285 | 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 286 | 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 287 | 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 288 | 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 289 | 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 290 | 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 291 | 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 292 | 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 293 | 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 294 | 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 295 | 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 296 | 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 297 | 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 298 | 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 299 | 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 300 | 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 301 | 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 302 | 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 303 | 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 304 | 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 305 | 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L 306 | }; 307 | 308 | USERTYPE square(USERTYPE arg) 309 | { 310 | return (arg*arg); 311 | } 312 | 313 | USERTYPE succ2(USERTYPE arg) 314 | { 315 | printf("(%d) Succ(%lld)\n",rank,arg++); 316 | return (arg); 317 | } 318 | 319 | USERTYPE product2(USERTYPE arg1, USERTYPE arg2) 320 | { 321 | printf("(%d) %lld * %lld = %lld\n",rank,arg1,arg2,arg1*arg2); 322 | return (arg1*arg2); 323 | } 324 | 325 | 326 | USERTYPE add2(USERTYPE arg1, USERTYPE arg2) 327 | { 328 | printf("(%d) %lld + %lld = %lld\n",rank,arg1,arg2,arg1+arg2); 329 | 330 | return (arg1+arg2); 331 | } 332 | 333 | USERTYPE show(USERTYPE arg) 334 | { 335 | printf("(%d) Show (%lld)\n",rank,arg); 336 | 337 | return (arg); 338 | } 339 | 340 | USERTYPE show2(USERTYPE arg1, USERTYPE arg2) 341 | { 342 | printf("(%d) ShowPair (%lld,%lld)\n",rank,arg1,arg2); 343 | 344 | return (arg1); 345 | } 346 | 347 | 348 | USERTYPE checksum(USERTYPE key) 349 | { 350 | USERTYPE check = key; 351 | int i; 352 | unsigned long size = sizeof(CRCTable)/4; 353 | 354 | printf("\n (%d) Key %lld ",rank,key); 355 | for (i=0; i