}
if(state.MULTICORE) {
outmethod.println("#include \"task.h\"");
+ outmethod.println("#include \"multicoreruntime.h\"");
+ outmethod.println("#include \"runtime_arch.h\"");
}
if (state.THREAD||state.DSM||state.SINGLETM)
outmethod.println("#include <thread.h>");
/* generate print information for RAW version */
output.println("#ifdef MULTICORE");
- output.println("{");
- output.println("int tmpsum = 0;");
- output.println("char * taskname = \"" + task.getSymbol() + "\";");
- output.println("int tmplen = " + task.getSymbol().length() + ";");
- output.println("int tmpindex = 1;");
- output.println("for(;tmpindex < tmplen; tmpindex++) {");
- output.println(" tmpsum = tmpsum * 10 + *(taskname + tmpindex) - '0';");
- output.println("}");
+ if(this.state.RAW) {
+ output.println("{");
+ output.println("int tmpsum = 0;");
+ output.println("char * taskname = \"" + task.getSymbol() + "\";");
+ output.println("int tmplen = " + task.getSymbol().length() + ";");
+ output.println("int tmpindex = 1;");
+ output.println("for(;tmpindex < tmplen; tmpindex++) {");
+ output.println(" tmpsum = tmpsum * 10 + *(taskname + tmpindex) - '0';");
+ output.println("}");
+ }
output.println("#ifdef RAWPATH");
- output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
- output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
- output.println("BAMBOO_DEBUGPRINT(BAMBOO_GET_EXE_TIME());");
+ if(this.state.RAW) {
+ output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
+ output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
+ } else {
+ output.println("tprintf(\"Process %x(%d): task %s\\n\", corenum, corenum, \"" + task.getSymbol() + "\");");
+ }
+ output.println("BAMBOO_DEBUGPRINT((int)BAMBOO_GET_EXE_TIME());");
output.println("#endif");
output.println("#ifdef DEBUG");
- output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
- output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
- output.println("#endif");
- output.println("}");
+ if(this.state.RAW) {
+ output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
+ output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
+ } else {
+ output.println("tprintf(\"Process %x(%d): task %s\\n\", corenum, corenum, \"" + task.getSymbol() + "\");");
+ }
output.println("#endif");
+ if(this.state.RAW) {
+ output.println("}");
+ }
+ output.println("#endif");
for(int i = 0; i < fm.numParameters(); ++i) {
TempDescriptor temp = fm.getParameter(i);
public String OWNERSHIPALIASFILE=null;
public boolean OPTIONAL=false;
public boolean ARRAYBOUNDARYCHECK=true;
+ public boolean RAW=false;
public boolean SCHEDULING=false;
public boolean USEPROFILE=false;
public boolean THREAD=false;
state.OPTIMIZE=true;
else if (option.equals("-dcopts"))
state.DCOPTS=true;
+ else if (option.equals("-raw"))
+ state.RAW=true;
else if (option.equals("-scheduling"))
state.SCHEDULING=true;
else if (option.equals("-distributioninfo"))
#include <stdio.h>
#include <sys/types.h>
+#ifndef MULTICORE
#include <sys/stat.h>
#include <fcntl.h>
+#endif
#include <stdlib.h>
#include <limits.h>
return ptr->object;
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p\n",key);
#endif
return NULL;
return NULL;
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p...\n Likely concurrent removal--bad user!!!\n",key);
#endif
return NULL;
}
ptr=ptr->next;
}
-#ifndef RAW
+#ifndef MULTICORE
printf("XXXXXXXXX: COULDN'T FIND ENTRY FOR KEY %p\n",key);
#endif
}
+#ifndef MULTICORE
#include <fcntl.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#endif
+#include <sys/types.h>
#include "structdefs.h"
#include "mem.h"
#include "runtime.h"
void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off, int len, int fd, struct ArrayObject * ___array___, int off, int len) {
+#ifdef MULTICORE
+#else
char * string= (((char *)&VAR(___array___)->___length___)+sizeof(int));
int status=write(fd, &string[off], len);
+#endif
}
void CALL11(___FileOutputStream______nativeClose____I, int fd, int fd) {
+#ifdef MULTICORE
+#else
close(fd);
+#endif
}
void CALL11(___FileOutputStream______nativeFlush____I, int fd, int fd) {
// not supported in RAW version
-#ifndef RAW
+#ifdef MULTICORE
+#else
fsync(fd);
#endif
}
int CALL01(___FileOutputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
+#ifdef MULTICORE
+ return 0;
+#else
int length=VAR(___filename___)->___length___;
char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
int fd=open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
return fd;
+#endif
}
int CALL01(___FileOutputStream______nativeAppend_____AR_B, struct ArrayObject * ___filename___) {
+#ifdef MULTICORE
+ return 0;
+#else
int length=VAR(___filename___)->___length___;
char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
int fd=open(filename, O_WRONLY|O_CREAT|O_APPEND, S_IRWXU);
return fd;
+#endif
}
int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
+#ifdef MULTICORE
+ return 0;
+#else
int length=VAR(___filename___)->___length___;
char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int));
int fd=open(filename, O_RDONLY, 0);
return fd;
+#endif
}
void CALL11(___FileInputStream______nativeClose____I, int fd, int fd) {
+#ifdef MULTICORE
+#else
close(fd);
+#endif
}
int CALL23(___FileInputStream______nativeRead____I__AR_B_I, int fd, int numBytes, int fd, struct ArrayObject * ___array___, int numBytes) {
+#ifdef MULTICORE
+ return -1;
+#else
int toread=VAR(___array___)->___length___;
char* string= (((char *)&VAR(___array___)->___length___)+sizeof(int));
int status;
status=read(fd, string, toread);
return status;
+#endif
}
int CALL11(___FileInputStream______nativePeek____I, int fd, int fd) {
+#ifdef MULTICORE
+ return 0;
+#else
int status;
char string[1];
status=read(fd, string, 1);
}
lseek(fd, -1, SEEK_CUR);
return string[0];
+#endif
}
long long CALL01(___File______nativeLength_____AR_B, struct ArrayObject * ___pathname___) {
+#ifdef MULTICORE
+ return 0;
+#else
int length=VAR(___pathname___)->___length___;
char* filename= (((char *)&VAR(___pathname___)->___length___)+sizeof(int));
struct stat st;
stat(filename, &st);
return st.st_size;
+#endif
}
#include "runtime.h"
+#ifdef MULTICORE
+#ifdef RAW
#include "math.h"
+#endif
+#else
+#include "math.h"
+#endif
#include "structdefs.h"
-
+#if 0
double CALL11(___Math______cos____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return cos(___a___);
+#endif
+#else
return cos(___a___);
+#endif
}
double CALL11(___Math______sin____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return sin(___a___);
+#endif
+#else
+ return sin(___a___);
+#endif
}
double CALL11(___Math______tan____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return tan(___a___);
+#endif
+#else
return tan(___a___);
+#endif
}
double CALL11(___Math______acos____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return acos(___a___);
+#endif
+#else
+ return acos(___a___);
+#endif
}
double CALL11(___Math______asin____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return asin(___a___);
+#endif
+#else
return asin(___a___);
+#endif
}
double CALL11(___Math______atan____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return atan(___a___);
+#endif
+#else
return atan(___a___);
+#endif
}
double CALL22(___Math______atan2____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return atan2(___a___,___b___);
+#endif
+#else
+ return atan2(___a___,___b___);
+#endif
}
double CALL11(___Math______log____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return log(___a___);
+#endif
+#else
return log(___a___);
+#endif
}
double CALL11(___Math______exp____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return exp(___a___);
+#endif
+#else
+ return exp(___a___);
+#endif
}
double CALL11(___Math______sqrt____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return -1;
+#ifdef RAW
+ return sqrt(___a___);
+#endif
+#else
return sqrt(___a___);
+#endif
}
double CALL22(___Math______pow____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return pow(___a___);
+#endif
+#else
return pow(___a___,___b___);
+#endif
}
double CALL11(___Math______ceil____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return ceil(___a___);
+#endif
+#else
return ceil(___a___);
+#endif
}
double CALL11(___Math______floor____D, double ___a___, double ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return floor(___a___);
+#endif
+#else
+ return floor(___a___);
+#endif
}
float CALL11(___Math______cosf____F, float ___a___, float ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return cosf(___a___);
+#endif
+#else
return cosf(___a___);
+#endif
}
float CALL11(___Math______sinf____F, float ___a___, float ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return sinf(___a___);
+#endif
+#else
+ return sinf(___a___);
+#endif
}
float CALL11(___Math______expf____F, float ___a___, float ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return expf(___a___);
+#endif
+#else
return expf(___a___);
+#endif
}
float CALL11(___Math______sqrtf____F, float ___a___, float ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return sqrtf(___a___);
+#endif
+#else
return sqrtf(___a___);
+#endif
}
float CALL11(___Math______logf____F, float ___a___, float ___a___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
return logf(___a___);
+#endif
+#else
+ return logf(___a___);
+#endif
}
float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
+#ifdef MULTICORE
+ return 1;
+#ifdef RAW
+ return powf(___a___,___b___);
+#endif
+#else
return powf(___a___,___b___);
+#endif
}
+#endif
#include "runtime.h"
#include "structdefs.h"
-#include <signal.h>
#include "mem.h"
+#ifndef MULTICORE
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
+#endif
#ifndef RAW
#include <stdio.h>
#endif
//#include "option.h"
extern int classsize[];
+#ifndef MULTICORE
jmp_buf error_handler;
int instructioncount;
char *options;
int injectfailures=0;
float failurechance=0;
-int debugtask=0;
int errors=0;
int injectinstructionfailures;
int failurecount;
#ifdef DMALLOC
#include "dmalloc.h"
#endif
+#endif
+
+int debugtask=0;
#ifdef MULTICORE
void initializeexithandler() {
//v->numlocks = 0;
v->lock = NULL;
if (length<0) {
-#ifndef RAW
+#ifndef MULTICORE
printf("ERROR: negative array\n");
#endif
return NULL;
exit(-1);
#endif
#else
+#ifndef MULTICORE
+ printf("Array out of bounds\n");
longjmp(error_handler,2);
#endif
+#endif
}
/* Abort task call */
void abort_task() {
#ifdef TASK
+#ifndef MULTICORE
+ printf("Aborting\n");
longjmp(error_handler,4);
+#endif
#else
printf("Aborting\n");
exit(-1);
if ((struct ___TagDescriptor___ *)tagptr==tagd)
obj->___tags___=NULL;
else
-#ifndef RAW
+#ifndef MULTICORE
printf("ERROR 1 in tagclear\n");
#else
;
goto PROCESSCLEAR;
}
}
-#ifndef RAW
+#ifndef MULTICORE
printf("ERROR 2 in tagclear\n");
#endif
}
if (tagset==obj)
tagd->flagptr=NULL;
else
-#ifndef RAW
+#ifndef MULTICORE
printf("ERROR 3 in tagclear\n");
#else
;
goto ENDCLEAR;
}
}
-#ifndef RAW
+#ifndef MULTICORE
printf("ERROR 4 in tagclear\n");
#endif
}
}
#endif
+#ifndef MULTICORE
fd_set readfds;
int maxreadfd;
struct RuntimeHash *fdtoobject;
maxreadfd--;
}
}
+#endif
#ifdef PRECISE_GC
#define OFFSET 2
/* Zero fd set */
FD_ZERO(&readfds);
#endif
+#ifndef MULTICORE
maxreadfd=0;
+#endif
#if 0
fdtoobject=allocateRuntimeHash(100);
#endif
#endif
newtask:
+#ifdef MULTICORE
+ while(hashsize(activetasks)>0) {
+#else
while((hashsize(activetasks)>0)||(maxreadfd>0)) {
+#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe990);
ObjectHashget(pw->objectset, (int) parameter, (int *) &next, (int *) &enterflags, &UNUSED, &UNUSED2);
ObjectHashremove(pw->objectset, (int)parameter);
if (enterflags!=NULL)
- free(enterflags);
+ RUNFREE(enterflags);
// release grabbed locks
for(j = 0; j < locklen; ++j) {
int * lock = (int *)(locks[j]->redirectlock);
//void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse);
#endif
#endif // #if 0: for recovery
+#ifndef MULTICORE
if (x=setjmp(error_handler)) {
//int counter;
/* Recover */
#ifdef DEBUG
-#ifndef RAW
+#ifndef MULTICORE
printf("Fatal Error=%d, Recovering!\n",x);
#endif
#endif
BAMBOO_DEBUGPRINT_REG(x);
BAMBOO_EXIT(0xa020);
} else {
+#endif
#if 0
if (injectfailures) {
if ((((double)random())/RAND_MAX)<failurechance) {
#endif
if(debugtask) {
-#ifndef RAW
- printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
+#ifndef MULTICORE
+ printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
#endif
((void(*) (void **))currtpd->task->taskptr)(taskpointerarray);
-#ifndef RAW
+#ifndef MULTICORE
printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
#endif
} else {
}
}
}
+#ifndef MULTICORE
}
+#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xe99b);
#endif
}
for(i=0; i<numtasks[corenum]; i++) {
struct taskdescriptor * task=taskarray[BAMBOO_NUM_OF_CORE][i];
-#ifndef RAW
+#ifndef MULTICORE
printf("%s\n", task->name);
#endif
for(j=0; j<task->numParameters; j++) {
struct parameterwrapper *parameter=param->queue;
struct ObjectHash * set=parameter->objectset;
struct ObjectIterator objit;
-#ifndef RAW
+#ifndef MULTICORE
printf(" Parameter %d\n", j);
#endif
ObjectHashiterator(set, &objit);
int numflags=Objdata3(&objit);
int flags=Objdata2(&objit);
Objnext(&objit);
-#ifndef RAW
+#ifndef MULTICORE
printf(" Contains %lx\n", obj);
printf(" flag=%d\n", obj->flag);
#endif
if (tagptr==NULL) {
} else if (tagptr->type==TAGTYPE) {
-#ifndef RAW
+#ifndef MULTICORE
printf(" tag=%lx\n",tagptr);
#else
;
int tagindex=0;
struct ArrayObject *ao=(struct ArrayObject *)tagptr;
for(; tagindex<ao->___cachedCode___; tagindex++) {
-#ifndef RAW
+#ifndef MULTICORE
printf(" tag=%lx\n",ARRAYGET(ao, struct ___TagDescriptor___*, tagindex));
#else
;
#ifndef RUNTIME
#define RUNTIME
+#ifndef MULTICORE
#include <setjmp.h>
extern jmp_buf error_handler;
extern int instructioncount;
extern int failurecount;
+#endif
#ifdef DSTM
#include "dstm.h"
#endif
#include "runtime.h"
#include "structdefs.h"
-#include <fcntl.h>
#ifndef MULTICORE
+#include <fcntl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <strings.h>
#include <netdb.h>
#include <netinet/tcp.h>
-#endif
#include <errno.h>
+#endif
#include "SimpleHash.h"
#include "GenericHashtable.h"
}
void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, struct ___Socket___ * ___this___, struct ArrayObject * ___b___, int offset, int length) {
+#ifdef MULTICORE
+#else
int fd=VAR(___this___)->___fd___;
char * charstr=((char *)&VAR(___b___)->___length___)+sizeof(int)+offset;
while(1) {
}
if (length!=0) {
-#ifndef MULTICORE
perror("ERROR IN NATIVEWRITE");
printf("error=%d remaining bytes %d\n",errno, length);
-#endif
}
break;
}
+#endif
}
int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___, struct ArrayObject * ___b___) {
+#ifdef MULTICORE
+ return -1;
+#else
int fd=VAR(___this___)->___fd___;
int length=VAR(___b___)->___length___;
#endif
#endif
return byteread;
+#endif
}
void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
echo -printschedulesim print out scheduling simulator result graphs
echo -abcclose close the array boundary check
echo "-tilera generate tilera version binary (should be used together with -multicore"
+echo "-tileraconfig config tilera simulator/pci as nxm (should be used together with -tilera)"
echo "-raw generate raw version binary (should be used together with -multicore)"
echo "-rawconfig config raw simulator as 4xn (should be used together with -raw)"
echo -threadsimulate generate multi-thread simulate version binary
MULTICOREFLAG=false
RAWFLAG=false
TILERAFLAG=false
+TILERACONFIG=''
CACHEFLUSHFLAG=false
RAWCONFIG=''
DEBUGFLAG=false
elif [[ $1 = '-raw' ]]
then
RAWFLAG=true
+JAVAOPTS="$JAVAOPTS -raw"
elif [[ $1 = '-tilera' ]]
then
TILERAFLAG=true
+elif [[ $1 = '-tileraconfig' ]]
+then
+TILERACONFIG="$2"
+shift
elif [[ $1 = '-cacheflush' ]]
then
CACHEFLUSHFLAG=true
elif $TILERAFLAG
then # TILERAFLAG
TILERADIR="$CURDIR/tilera"
-MAKEFILE="Makefile.tilera"
+MAKEFILE="Makefile.tilera.$TILERACONFIG"
+SIMHVC="sim.hvc.$TILERACONFIG"
mkdir $TILERADIR
cd $TILERADIR
make clean
fi #INTERRUPT version
cp $ROBUSTROOT/Runtime/Tilera/$MAKEFILE ./Makefile
+cp $ROBUSTROOT/Runtime/Tilera/$SIMHVS ./sim.hvc
cp ../Runtime/multicoretask.c ./
cp ../Runtime/multicoreruntime.c ./
cp ../Runtime/Queue.c ./
cp ../Runtime/SimpleHash.c ./
cp ../Runtime/ObjectHash.c ./
cp ../Runtime/socket.c ./
-cp ../Runtime/taskdefs.c ./
-cp ../Runtime/methods.c ./
cp ../Runtime/mem.c ./
cp ../Runtime/GenericHashtable.h ./
cp ../Runtime/mem.h ./