dchashlistnode_t *tmpptr=dc_c_list;
while(tmpptr!=NULL) {
dchashlistnode_t *next=tmpptr->lnext;
- if (tmpptr>=ptr&&tmpptr<top) {
+ if (likely(tmpptr>=ptr)&&likely(tmpptr<top)) {
/*zero in list */
tmpptr->key=NULL;
tmpptr->next=NULL;
--- /dev/null
+#include <stdio.h>
+#include <pthread.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sched.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <runtime.h>
+
+static volatile unsigned int corecount=0;
+
+
+static inline int atomicinc(volatile unsigned int *lock) {
+ int retval=1;
+ __asm__ __volatile__("lock; xadd %0,%1"
+ : "=r"(retval)
+ : "m"(*lock), "0"(retval)
+ : "memory");
+ return retval;
+}
+
+
+void set_affinity() {
+ int err;
+ cpu_set_t cpumask;
+
+ CPU_ZERO(&cpumask);
+
+ int ourcount=atomicinc(&corecount);
+ ourcount=ourcount&7;
+ int newvalue=ourcount>>1;
+ if (ourcount&1) {
+ newvalue=newvalue|4;
+ }
+
+ CPU_SET(newvalue, &cpumask);
+
+ err = sched_setaffinity(syscall(SYS_gettid), sizeof(cpu_set_t), &cpumask);
+
+ if (err == -1)
+ printf("set_affinity: %s\n", strerror(errno));
+}
#endif
#endif
+#ifdef AFFINITY
+void set_affinity();
+#endif
+
#ifndef INTPTR
#ifdef BIT64
#define INTPTR long
#endif
processOptions();
initializeexithandler();
+#ifdef AFFINITY
+ set_affinity();
+#endif
//deprecated use of sighandler, but apparently still works
#ifdef SANDBOX
#if defined(THREADS)||defined(STM)
void initthread(struct ___Thread___ * ___this___) {
+#ifdef AFFINITY
+ set_affinity();
+#endif
#ifdef SANDBOX
struct sigaction sig;
abortenabled=0;
echo "-stmarray partial array treatment"
echo "-dualview dual view of arrays"
echo "-hybrid use fission only when it looks like a good choice"
+echo "-numa numa aware"
echo
echo DSM options
echo -dsm distributed shared memory
}
tmpbuilddirectory="tmpbuilddirectory"
+NUMA=false;
SANDBOX=false;
ABORTREADERS=false;
ROBUSTROOT=~/research/Robust/src
SANDBOX=true
EXTRAOPTIONS="$EXTRAOPTIONS -DSANDBOX"
JAVAOPTS="$JAVAOPTS -sandbox"
+elif [[ $1 = '-numa' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DAFFINITY -D_GNU_SOURCE"
+NUMA=true
elif [[ $1 = '-robustroot' ]]
then
ROBUSTROOT="$2"
$ROBUSTROOT/Runtime/math.c \
$ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"
+if $NUMA
+then
+FILES="$FILES $ROBUSTROOT/Runtime/affinity.c"
+fi
+
if $FASTMEMCPY
then
FILES="$FILES $ROBUSTROOT/Runtime/memcpy32.o $ROBUSTROOT/Runtime/instrset32.o"