#ifdef MULTICORE
-
#include "runtime.h"
#include "multicoreruntime.h"
#include "methodheaders.h"
#include "multicoregarbage.h"
+#ifdef PMC_GC
+#include "multicoregcprofile.h"
+#include "multicoregc.h"
+#include "pmc_garbage.h"
+#endif
+#include "multicore_arch.h"
+#include <stdio.h>
+#ifdef PERFCOUNT
+#include "bme_perf_counter.h"
+#endif
extern int classsize[];
extern int typearray[];
}
return num;
}
-#else
-int CALL12(___String______convertdoubletochar____D__AR_C,
- double ___val___,
- double ___val___,
- struct ArrayObject ___chararray___) {
- return 0;
-}
#endif
#ifdef D___System______deepArrayCopy____L___Object____L___Object___
}
#endif
+#ifdef D___System______exit____I
void CALL11(___System______exit____I,
int ___status___,
int ___status___) {
// gc_profile mode, output gc prfiling data
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
BAMBOO_PRINT(BAMBOO_GET_EXE_TIME());
BAMBOO_PRINT(0xbbbbbbbb);
CACHEADAPT_DISABLE_TIMER();
GC_OUTPUT_PROFILE_DATA();
+#ifdef PERFCOUNT
+ print_statistics();
+#endif
+ gc_outputProfileDataReadable();
+ tprintf("FINISH_EXECUTION\n");
}
#endif
BAMBOO_EXIT_APP(___status___);
}
+#endif
#ifdef D___Vector______removeElement_____AR_L___Object____I_I
void CALL23(___Vector______removeElement_____AR_L___Object____I_I,
}
#endif
+#ifdef D___System______printI____I
void CALL11(___System______printI____I,
int ___status___,
int ___status___) {
BAMBOO_PRINT(0x1111);
BAMBOO_PRINT_REG(___status___);
}
+#endif
+#ifdef D___System______currentTimeMillis____
long long CALL00(___System______currentTimeMillis____) {
//TilePro64 is 700mHz
return ((unsigned long long)BAMBOO_GET_EXE_TIME())/700000;
}
+#endif
+#ifdef D___System______setgcprofileflag____
void CALL00(___System______setgcprofileflag____) {
#ifdef GC_PROFILE
#ifdef MGC_SPEC
#endif
#endif
}
+#endif
+#ifdef D___System______resetgcprofileflag____
void CALL00(___System______resetgcprofileflag____) {
#ifdef GC_PROFILE
#ifdef MGC_SPEC
#endif
#endif
}
+#endif
-void CALL01(___System______printString____L___String___,
- struct ___String___ * ___s___) {
-#ifdef MGC
-#ifdef TILERA_BME
+#ifdef D___System______gc____
+void CALL00(___System______gc____) {
+#ifdef MULTICORE_GC
+ if(BAMBOO_NUM_OF_CORE == STARTUPCORE) {
+ if(!gc_status_info.gcprocessing && !gcflag) {
+ gcflag = true;
+ gcprecheck = true;
+ for(int i = 0; i < NUMCORESACTIVE; i++) {
+ // reuse the gcnumsendobjs & gcnumreceiveobjs
+ gcnumsendobjs[0][i] = 0;
+ gcnumreceiveobjs[0][i] = 0;
+ }
+ for(int i = 0; i < NUMCORES4GC; i++) {
+ if(i != STARTUPCORE) {
+ send_msg_1_I(i,GCSTARTPRE);
+ }
+ }
+ }
+ } else {
+ // send msg to the startup core to start gc
+ send_msg_1(STARTUPCORE, GCINVOKE);
+ }
+#endif
+}
+#endif
+
+#ifdef D___System______printString____L___String___
+void CALL01(___System______printString____L___String___, struct ___String___ * ___s___) {
+#if defined(MGC)&&defined(TILERA_BME)
struct ArrayObject * chararray=VAR(___s___)->___value___;
int i;
int offset=VAR(___s___)->___offset___;
((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
printf("%c", sc);
}
-#endif // TILERA_BME
#endif // MGC
}
+#endif
/* Object allocation function */
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
void * allocate_new(void * ptr,
int type) {
struct ___Object___ * v=
v->lockcount = 0;
#endif
initlock(v);
-#ifdef GC_PROFILE
- extern unsigned int gc_num_obj;
- gc_num_obj++;
-#endif
return v;
}
return NULL;
}
v->___length___=length;
- initlock(v);
-#ifdef GC_PROFILE
- extern unsigned int gc_num_obj;
- gc_num_obj++;
-#endif
+ initlock((struct ___Object___ *)v);
return v;
}
v->lock = NULL;
#endif
v->___length___=length;
- initlock(v);
+ initlock((struct ___Object___ *) v);
return v;
}
#endif
/* Converts C character arrays into Java strings */
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
__attribute__((malloc)) struct ___String___ * NewStringShort(void * ptr,
const short *str,
int length) {
int length) {
#endif
int i;
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
struct ArrayObject * chararray=
allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
}
/* Converts C character arrays into Java strings */
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
struct ___String___ * NewString(void * ptr,
const char *str,
int length) {
int length) {
#endif
int i;
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
struct ArrayObject * chararray=
allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
int ptrarray[]={1, (int) ptr, (int) chararray};
/* Generated code calls this if we fail a bounds check */
-void failedboundschk(int num) {
+ void failedboundschk(int num, int index, struct ArrayObject * ao) {
#ifndef TASK
- printf("Array out of bounds\n");
+ printf("Array out of bounds at line %u with index %u of object %x with lengt\
+h %u\n", num, index, ao, ao->___length___);
#ifdef THREADS
threadexit();
#elif defined MGC
/* Generated code calls this if we fail null ptr chk */
void failednullptr(void * ptr) {
-#ifdef MULTICORE_GC
+#if defined(MULTICORE_GC)||defined(PMC_GC)
#ifndef RAW
//print out current stack
int i,j;
#endif
}
-INLINE void initruntimedata() {
- int i;
+void initruntimedata() {
// initialize the arrays
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
// startup core to initialize corestatus[]
- for(i = 0; i < NUMCORESACTIVE; ++i) {
+ for(int i = 0; i < NUMCORESACTIVE; ++i) {
corestatus[i] = 1;
numsendobjs[i] = 0;
numreceiveobjs[i] = 0;
self_numsendobjs = 0;
self_numreceiveobjs = 0;
- for(i = 0; i < BAMBOO_MSG_BUF_LENGTH; ++i) {
+ for(int i = 0; i < BAMBOO_MSG_BUF_LENGTH; ++i) {
msgdata[i] = -1;
}
msgdataindex = 0;
msgdatalast = 0;
//msglength = BAMBOO_MSG_BUF_LENGTH;
msgdatafull = false;
- for(i = 0; i < BAMBOO_OUT_BUF_LENGTH; ++i) {
+ for(int i = 0; i < BAMBOO_OUT_BUF_LENGTH; ++i) {
outmsgdata[i] = -1;
}
outmsgindex = 0;
outmsglast = 0;
outmsgleft = 0;
isMsgHanging = false;
-
+
smemflag = true;
bamboo_cur_msp = NULL;
bamboo_smem_size = 0;
#ifdef MGC
initializethreads();
- bamboo_current_thread = 0;
+ bamboo_current_thread = NULL;
#endif // MGC
INITTASKDATA();
}
-INLINE void disruntimedata() {
+void disruntimedata() {
DISMULTICOREGCDATA();
DISTASKDATA();
BAMBOO_LOCAL_MEM_CLOSE();
BAMBOO_SHARE_MEM_CLOSE();
}
-INLINE void recordtotalexetime() {
+void recordtotalexetime() {
#ifdef USEIO
totalexetime = BAMBOO_GET_EXE_TIME()-bamboo_start_time;
#else // USEIO
- BAMBOO_PRINT(BAMBOO_GET_EXE_TIME()-bamboo_start_time);
+ unsigned long long timediff=BAMBOO_GET_EXE_TIME()-bamboo_start_time;
+ BAMBOO_PRINT(timediff);
#ifndef BAMBOO_MEMPROF
BAMBOO_PRINT(0xbbbbbbbb);
#endif
#endif // USEIO
}
-INLINE void getprofiledata_I() {
+void getprofiledata_I() {
//profile mode, send msgs to other cores to request pouring out progiling data
#ifdef PROFILE
// use numconfirm to check if all cores have finished output task profiling
#endif
}
-INLINE void checkCoreStatus() {
+void checkCoreStatus() {
int i = 0;
int sumsendobj = 0;
if((!waitconfirm) ||
getprofiledata_I();
CACHEADAPT_DISABLE_TIMER();
GC_OUTPUT_PROFILE_DATA();
+#ifdef PERFCOUNT
+ print_statistics();
+#endif
+ gc_outputProfileDataReadable();
disruntimedata();
+ tprintf("FINISH_EXECUTION\n");
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
terminate(); // All done.
}
}
// main function for each core
-inline void run(int argc, char** argv) {
- int i = 0;
+void run(int argc, char** argv) {
bool sendStall = false;
bool isfirst = true;
bool tocontinue = false;
-
+ startflag = false;
corenum = BAMBOO_GET_NUM_OF_CORE();
-
// initialize runtime data structures
initruntimedata();
-
- // other architecture related initialization
- initialization();
initCommunication();
+#ifdef PMC_GC
+ pmc_onceInit();
+#endif
+#ifdef PERFCOUNT
+ if (BAMBOO_NUM_OF_CORE==STARTUPCORE)
+ profile_init(_LOCAL_DRD_CNT,_LOCAL_WR_CNT, _REMOTE_DRD_CNT, _REMOTE_WR_CNT);
+ else {
+ int offcore=4*(BAMBOO_NUM_OF_CORE-1);
+ profile_init(validevents[(offcore)%87], validevents[(offcore+1)%87], validevents[(offcore+2)%87], validevents[(offcore+3)%87]);
+ }
+#endif
+ if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
+ numconfirm=NUMCORES-1;
+ for(int i=0;i<NUMCORES;i++) {
+ if (i!=STARTUPCORE) {
+ send_msg_1(i,REQNOTIFYSTART);
+ }
+ }
+ while(numconfirm!=0)
+ ;
+ tprintf("START_EXECUTION\n");
+ bamboo_start_time = BAMBOO_GET_EXE_TIME();
+ } else {
+ while(!startflag)
+ ;
+ }
+#ifdef PERFCOUNT
+ bme_performance_counter_start();
+#endif
CACHEADAPT_ENABLE_TIMER();
#ifdef TASK
/* Create queue of active tasks */
activetasks= genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd,
- (int (*)(void *,void *)) &comparetpd);
-
+ (int (*)(void *,void *)) &comparetpd);
+
/* Process task information */
processtasks();
-
+
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
/* Create startup object */
createstartupobject(argc, argv);
}
#endif
-
- if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
+
+#ifdef PERFCOUNT
+ profile_start(APP_REGION);
+#endif
+ if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
#ifdef TASK
- // run the initStaticAndGlobal method to initialize the static blocks and
- // global fields
- initStaticAndGlobal();
+ // run the initStaticAndGlobal method to initialize the static blocks and
+ // global fields
+ initStaticAndGlobal();
#elif defined MGC
- // run the main method in the specified mainclass
- mgc_main(argc, argv);
+ // run the main method in the specified mainclass
+ mgc_main(argc, argv);
#endif // TASK
- }
-
+ }
+
while(true) {
GCCHECK(NULL);
#ifdef TASK
sendStall = false;
}
#endif
-
+
if(!tocontinue) {
// check if stop
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
#ifdef PROFILE
if(!stall) {
#endif
- if(isfirst) {
- // wait for some time
- int halt = 10000;
- while(halt--) {
- }
- isfirst = false;
- } else {
- // send StallMsg to startup core
- // send stall msg
- send_msg_4(STARTUPCORE,TRANSTALL,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
- sendStall = true;
- isfirst = true;
- busystatus = false;
- }
+ if(isfirst) {
+ // wait for some time
+ int halt = 10000;
+ while(halt--) {
+ }
+ isfirst = false;
+ } else {
+ // send StallMsg to startup core
+ // send stall msg
+ send_msg_4(STARTUPCORE,TRANSTALL,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
+ sendStall = true;
+ isfirst = true;
+ busystatus = false;
+ }
#ifdef PROFILE
}
#endif
}
}
}
-}
-
+}
+
#endif // MULTICORE