//System.out.println("myId= " + myId + " start= " + start + " npoints= " + npoints);
while (start < npoints) {
stop = (((start + CHUNK) < npoints) ? (start + CHUNK) : npoints);
+
for (int i = start; i < stop; i++) {
index = Common.common_findNearestPoint(feature[i],
nfeatures,
membership[i] = index;
/* Update new cluster centers : sum of objects located within */
- atomic {
+ atomic {
new_centers_len[index] = new_centers_len[index] + 1;
for (int j = 0; j < nfeatures; j++) {
new_centers[index][j] = new_centers[index][j] + feature[i][j];
}
- }
+ }
}
/* Update task queue */
if (start + CHUNK < npoints) {
- atomic {
+ atomic {
start = (int) args.global_i;
args.global_i = start + CHUNK;
}
Common.java \
GlobalArgs.java \
../../../ClassLibrary/JavaSTM/Barrier.java
-FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -transstats -joptimize
+FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -fastmemcpy -garbagestats
FLAGS2=-mainclass ${MAINCLASS} -optimize -debug -joptimize -thread
GridCell.java \
LeeThread.java \
WorkQueue.java
-FLAGS=-mainclass ${MAINCLASS} -joptimize -debug -singleTM -optimize -dcopts -transstats -abcclose -stmdebug -stmstats
+FLAGS=-mainclass ${MAINCLASS} -joptimize -debug -singleTM -optimize -dcopts -transstats -abcclose -stmstats
default:
../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
public void generateFlatAtomicEnterNode(FlatMethod fm, LocalityBinding lb, FlatAtomicEnterNode faen, PrintWriter output) {
/* Check to see if we need to generate code for this atomic */
- if (locality==null||locality.getAtomic(lb).get(faen.getPrev(0)).intValue()>0)
+ if (locality==null) {
+ output.println("pthread_mutex_lock(&atomiclock);");
+ return;
+ }
+
+ if (locality.getAtomic(lb).get(faen.getPrev(0)).intValue()>0)
return;
/* Backup the temps. */
for(Iterator<TempDescriptor> tmpit=locality.getTemps(lb).get(faen).iterator(); tmpit.hasNext();) {
public void generateFlatAtomicExitNode(FlatMethod fm, LocalityBinding lb, FlatAtomicExitNode faen, PrintWriter output) {
/* Check to see if we need to generate code for this atomic */
- if (locality==null||locality.getAtomic(lb).get(faen).intValue()>0)
+ if (locality==null) {
+ output.println("pthread_mutex_unlock(&atomiclock);");
+ return;
+ }
+ if (locality.getAtomic(lb).get(faen).intValue()>0)
return;
//store the revert list before we lose the transaction object
String revertptr=null;
pthread_mutex_t objlock;
pthread_cond_t objcond;
+pthread_mutex_t atomiclock;
+
pthread_mutex_t joinlock;
pthread_cond_t joincond;
pthread_key_t threadlocks;
#endif
pthread_mutex_lock(&gclistlock);
#ifdef THREADS
- pthread_setspecific(threadlocks, litem->locklist);
+ pthread_setspecific(threadlocks, litem.locklist);
#endif
#ifndef MAC
if (litem.prev==NULL) {
void initializethreads() {
struct sigaction sig;
threadcount=1;
+#ifdef THREADS
+ pthread_mutex_init(&atomiclock, NULL);
+#endif
pthread_mutex_init(&gclock, NULL);
pthread_mutex_init(&gclistlock, NULL);
pthread_cond_init(&gccond, NULL);
pthread_mutex_lock(&gclistlock);
#ifdef THREADS
- pthread_setspecific(threadlocks, litem->locklist);
+ pthread_setspecific(threadlocks, litem.locklist);
#endif
if (litem.prev==NULL) {
list=litem.next;
pthread_mutex_lock(&gclistlock);
#ifdef THREADS
- pthread_setspecific(threadlocks, litem->locklist);
+ pthread_setspecific(threadlocks, litem.locklist);
#endif
if (litem.prev==NULL) {
list=litem.next;
extern pthread_mutex_t objlock;
extern pthread_cond_t objcond;
extern pthread_key_t threadlocks;
+extern pthread_mutex_t atomiclock;
+
#if defined(THREADS)||defined(STM)
void initthread(struct ___Thread___ * ___this___);
#endif