+#define _GNU_SOURCE
#include "trqueue.h"
#include "stdlib.h"
#include "stdio.h"
+#include <sched.h>
#include "mlp_lock.h"
#include <pthread.h>
#include "structdefs.h"
ptr->head=0;
ptr->tail=0;
ptr->id=myid;
+#if COREPIN
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(myid, &cpuset);
+ pthread_attr_setaffinity_np(&nattr, sizeof(cpuset), &cpuset);
+ printf("assign workerTR to core %d\n",myid);
+#endif
ptr->allHashStructures=createAndFillMasterHashStructureArray();
- int status=pthread_create( &thread, NULL, workerTR, (void *) ptr);
+ int status=pthread_create( &thread, &nattr, workerTR, (void *) ptr);
+ // int status=pthread_create( &thread, NULL, workerTR, (void *) ptr);
if (status!=0) {printf("ERROR\n");exit(-1);}
pthread_attr_destroy(&nattr);
}
+#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
+#include <sched.h>
+#include <sys/syscall.h>
#include "mem.h"
#include "workschedule.h"
#endif
+
+
//////////////////////////////////////////////////
//
// for coordination with the garbage collector
#endif
dqInit( &(deques[i]) );
}
+
+#ifndef COREPIN
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr,
if( status != 0 ) { printf( "Error\n" ); exit( -1 ); }
}
+#else
+ int numCore=24;
+ cpu_set_t cpuset;
+ pthread_attr_t thread_attr[numWorkSchedWorkers];
+ int idx;
+
+ workerDataArray[0].id = 0;
+ CPU_ZERO(&cpuset);
+ CPU_SET(0, &cpuset);
+ sched_setaffinity(syscall(SYS_gettid), sizeof(cpuset), &cpuset);
+
+ for(idx=1;idx<numWorkSchedWorkers;idx++){
+ int coreidx=idx%numCore;
+ pthread_attr_t* attr = &thread_attr[idx];
+ pthread_attr_init(attr);
+ pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
+ CPU_ZERO(&cpuset);
+ CPU_SET(coreidx, &cpuset);
+ pthread_attr_setaffinity_np(attr, sizeof(cpuset), &cpuset);
+
+ workerDataArray[idx].id = idx;
+
+ status = pthread_create( &(workerDataArray[idx].workerThread),
+ attr,
+ workerMain,
+ (void*) &(workerDataArray[idx])
+ );
+ printf("assign %d on %d",idx,coreidx);
+
+ }
+#endif
}