static void disable_hyperthread(void) { unsigned long share; int cpu; common -> avail = (1UL << common -> num_procs) - 1; #ifdef DEBUG fprintf(stderr, "\nAvail CPUs : %04lx.\n", common -> avail); #endif for (cpu = 0; cpu < common -> num_procs; cpu ++) { share = (get_share(cpu, 1) & common -> avail); if (popcount(share) > 1) { #ifdef DEBUG fprintf(stderr, "Detected Hyper Threading on CPU %4x; disabled CPU %04lx.\n", cpu, share & ~(1UL << cpu)); #endif common -> avail &= ~((share & ~(1UL << cpu))); } } }
void pt_print_share(void) { int i, j; int nt = spcd_get_num_threads(); int sum = 0, sum_sqr = 0; int av, va; if (nt < 2) return; for (i = nt-1; i >= 0; i--) { for (j = 0; j < nt; j++) { int s = get_share(i,j); sum += s; sum_sqr += s*s; printk ("%u", s); if (j != nt-1) printk (","); } printk("\n"); } av = sum / nt / nt; va = (sum_sqr - ((sum*sum)/nt/nt))/(nt-1)/(nt-1); printk ("avg: %d, var: %d, hf: %d\n", av, va, av ? va/av : 0); }
static void disable_hyperthread(void) { unsigned long share[MAX_BITMASK_LEN]; int cpu; int bitmask_idx = 0; int i=0, count=0; bitmask_idx = CPUELT(common -> num_procs); for(i=0; i< bitmask_idx; i++){ common -> avail[count++] = 0xFFFFFFFFFFFFFFFFUL; } if(CPUMASK(common -> num_procs) != 1){ common -> avail[count++] = CPUMASK(common -> num_procs) - 1; } common -> avail_count = count; /* if(common->num_procs > 64){ */ /* fprintf(stderr, "\nOpenBLAS Warning : The number of CPU/Cores(%d) is beyond the limit(64). Terminated.\n", common->num_procs); */ /* exit(1); */ /* }else if(common->num_procs == 64){ */ /* common -> avail = 0xFFFFFFFFFFFFFFFFUL; */ /* }else */ /* common -> avail = (1UL << common -> num_procs) - 1; */ #ifdef DEBUG fprintf(stderr, "\nAvail CPUs : "); for(i=0; i<count; i++) fprintf(stderr, "%04lx ", common -> avail[i]); fprintf(stderr, ".\n"); #endif for (cpu = 0; cpu < common -> num_procs; cpu ++) { get_share(cpu, 1, share); //When the shared cpu are in different element of share & avail array, this may be a bug. for (i = 0; i < count ; i++){ share[i] &= common->avail[i]; if (popcount(share[i]) > 1) { #ifdef DEBUG fprintf(stderr, "Detected Hyper Threading on CPU %4x; disabled CPU %04lx.\n", cpu, share[i] & ~(CPUMASK(cpu))); #endif common -> avail[i] &= ~((share[i] & ~ CPUMASK(cpu))); } } } }