diff -ur torque-3.0.3.orig/src/include/pbs_nodes.h torque-3.0.3.modified/src/include/pbs_nodes.h --- torque-3.0.3.orig/src/include/pbs_nodes.h 2011-06-09 04:25:31.000000000 +0800 +++ torque-3.0.3.modified/src/include/pbs_nodes.h 2011-12-27 17:49:55.469715204 +0800 @@ -169,10 +169,12 @@ { int num_cpus; /* count of cpus */ - int cpu_offset; /* real index of first cpu */ +// int cpu_offset; /* real index of first cpu */ + int *cpu_list; /* list of cpu */ int index; /* the node's index */ int num_mems; /* count of memory nodes */ - int mem_offset; /* real index of first memory node */ + int *mem_list; /* list of memory node */ +// int mem_offset; /* real index of first memory node */ unsigned long memsize; char **path_meminfo; /* path to meminfo file */ diff -ur torque-3.0.3.orig/src/resmom/linux/cpuset.c torque-3.0.3.modified/src/resmom/linux/cpuset.c --- torque-3.0.3.orig/src/resmom/linux/cpuset.c 2011-07-13 06:07:28.000000000 +0800 +++ torque-3.0.3.modified/src/resmom/linux/cpuset.c 2011-12-27 17:36:47.179628660 +0800 @@ -787,6 +787,7 @@ #endif int j; + int i; char buf[MAXPATHLEN]; for (j = 0;j < pjob->ji_numvnod;++j, np++) @@ -819,20 +820,37 @@ if (CpuStr[0] != '\0') strcat(CpuStr,","); - sprintf(buf,"%d-%d", - numa_nodes[numa_index].cpu_offset, - numa_nodes[numa_index].cpu_offset + numa_nodes[numa_index].num_cpus); +/* sprintf(buf,"%d-%d",*/ +/* numa_nodes[numa_index].cpu_offset,*/ +/* numa_nodes[numa_index].cpu_offset + numa_nodes[numa_index].num_cpus);*/ + sprintf(buf,"%d", numa_nodes[numa_index].cpu_list[0]); strcat(CpuStr,buf); - + + for (i = 1; i < numa_nodes[numa_index].num_cpus; i++) + { + sprintf(buf,",%d", numa_nodes[numa_index].cpu_list[i]); + strcat(CpuStr,buf); + } + + printf("%s#", CpuStr); + if (MemStr[0] != '\0') strcat(MemStr,","); - sprintf(buf,"%d-%d", - numa_nodes[numa_index].mem_offset, - numa_nodes[numa_index].mem_offset + numa_nodes[numa_index].num_mems); - +/* sprintf(buf,"%d-%d",*/ +/* numa_nodes[numa_index].mem_offset,*/ +/* numa_nodes[numa_index].mem_offset + numa_nodes[numa_index].num_mems);*/ + + sprintf(buf,"%d", numa_nodes[numa_index].mem_list[0]); strcat(MemStr,buf); + + for (i = 1; i < numa_nodes[numa_index].num_mems; i++) + { + sprintf(buf,",%d", numa_nodes[numa_index].mem_list[i]); + strcat(MemStr,buf); + } + #else if (old_name == NULL) old_name = np->vn_host->hn_host; @@ -929,9 +947,11 @@ #ifdef NUMA_SUPPORT numa_tmp = numa_nodes + numa_index; - cpu_index = np->vn_index + numa_tmp->cpu_offset; +/* cpu_index = np->vn_index + numa_tmp->cpu_offset;*/ + cpu_index = numa_tmp->cpu_list[np->vn_index]; ratio = numa_tmp->num_cpus / numa_tmp->num_mems; - mem_index = (np->vn_index / ratio) + numa_tmp->mem_offset; +/* mem_index = (np->vn_index / ratio) + numa_tmp->mem_offset;*/ + mem_index = numa_tmp->mem_list[(np->vn_index / ratio)]; #else cpu_index = np->vn_index; #endif /* NUMA_SUPPORT */ diff -ur torque-3.0.3.orig/src/resmom/mom_main.c torque-3.0.3.modified/src/resmom/mom_main.c --- torque-3.0.3.orig/src/resmom/mom_main.c 2011-11-08 06:49:10.000000000 +0800 +++ torque-3.0.3.modified/src/resmom/mom_main.c 2011-12-27 17:48:23.390637661 +0800 @@ -8753,11 +8753,82 @@ +/* + * finds the number of elements in a comma-separated and range mixed string + */ +int get_list_count( + + char *str, /* I */ + int *list) /* O */ + +{ + int count = 0; + int id, end; + char *comma, *hyphen; + + /* check for error */ + if (str == NULL) + return(-1); + + while (*str != '\0') + { + comma = strchr(str, ','); + hyphen = strchr(str, '-'); + id = atoi(str); + + /* last piece */ + if (comma == NULL) + { + /* comma-separated format */ + if (hyphen == NULL) + { + count++; + *list++ = id; + } + + /* range format */ + else + { + end = atoi(hyphen+1); + for ( ; id <= end; id++, count++) + *list++ = id; + } + + break; + } + + /* comma-separated format */ + if (hyphen == NULL || comma < hyphen) + { + count++; + *list++ = id; + str = comma+1; + continue; + } + + /* range format */ + if (hyphen < comma) + { + end = atoi(hyphen+1); + for ( ; id <= end; id++, count++) + *list++ = id; + str = comma+1; + continue; + } + } + + return(count); + } /* END get_list_count() */ + + + + int read_layout_file() { FILE *read_layout; char line[MAX_LINE]; + int list[MAX_NUMA_NODES]; char *delims = " \t\n\r="; char *tok = NULL; char *val = NULL; @@ -8814,24 +8885,34 @@ if (strcmp(tok,"cpus") == 0) { /* save offset, lowest index must come first */ - numa_nodes[i].cpu_offset = atoi(val); +/* numa_nodes[i].cpu_offset = atoi(val);*/ /* find the node count */ - if (strchr(val,'-') != NULL) - numa_nodes[i].num_cpus = parse_range(val); - else - numa_nodes[i].num_cpus = get_comma_count(val); +/* if (strchr(val,'-') != NULL)*/ +/* numa_nodes[i].num_cpus = parse_range(val);*/ +/* else*/ +/* numa_nodes[i].num_cpus = get_comma_count(val);*/ + + /* find the cpu count and set cpu_list */ + numa_nodes[i].num_cpus = get_list_count(val, list); + numa_nodes[i].cpu_list = (int *)malloc(numa_nodes[i].num_cpus * sizeof(int)); + memmove(numa_nodes[i].cpu_list, list, numa_nodes[i].num_cpus * sizeof(int)); } else if (strcmp(tok,"mem") == 0) { int j; /* save offset, lowest index must come first */ - numa_nodes[i].mem_offset = atoi(val); +/* numa_nodes[i].mem_offset = atoi(val);*/ - if (strchr(val,'-') != NULL) - numa_nodes[i].num_mems = parse_range(val); - else - numa_nodes[i].num_mems = get_comma_count(val); +/* if (strchr(val,'-') != NULL)*/ +/* numa_nodes[i].num_mems = parse_range(val);*/ +/* else*/ +/* numa_nodes[i].num_mems = get_comma_count(val);*/ + + /* find the mem count and set mem_list */ + numa_nodes[i].num_mems = get_list_count(val, list); + numa_nodes[i].mem_list = (int *)malloc(numa_nodes[i].num_mems * sizeof(int)); + memmove(numa_nodes[i].mem_list, list, numa_nodes[i].num_mems * sizeof(int)); /* save the meminfo path stuff */ numa_nodes[i].path_meminfo = (char **)malloc(numa_nodes[i].num_mems * sizeof(char *)); @@ -8842,7 +8923,8 @@ snprintf(numa_nodes[i].path_meminfo[j],mempath_len, "/sys/devices/system/node/node%d/meminfo", - j + numa_nodes[i].mem_offset); + numa_nodes[i].mem_list[j]); +/* j + numa_nodes[i].mem_offset);*/ } }