Changeset 5629

Show
Ignore:
Timestamp:
10/29/09 23:03:36 (4 weeks ago)
Author:
balaji
Message:

Bug fix for the user-specified bindings code. Thanks to Guillaume to
pointing out this error.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/src/pm/hydra/tools/bind/bind.c

    r5482 r5629  
    4040    } 
    4141 
    42     if (!strncmp(binding, "user:", strlen("user:"))) { 
    43         /* If the user specified the binding, we don't need to 
    44          * initialize anything */ 
    45         bindstr = HYDU_strdup(binding + strlen("user:")); 
    46  
    47         /* Find the number of processing elements */ 
    48         HYDT_bind_info.num_procs = 0; 
    49         bindentry = strtok(bindstr, ","); 
    50         while (bindentry) { 
    51             HYDT_bind_info.num_procs++; 
    52             bindentry = strtok(NULL, ","); 
    53         } 
    54  
    55         /* Find the actual processing elements */ 
    56         HYDU_MALLOC(HYDT_bind_info.bindmap, int *, HYDT_bind_info.num_procs * sizeof(int), 
    57                     status); 
    58         i = 0; 
    59         bindentry = strtok(bindstr, ","); 
    60         while (bindentry) { 
    61             HYDT_bind_info.bindmap[i++] = atoi(bindentry); 
    62             bindentry = strtok(NULL, ","); 
    63         } 
    64  
    65         goto fn_exit; 
    66     } 
    67  
    68     /* If a real binding is required, we initialize the binding 
    69      * library requested by the user */ 
     42    /* Initialize the binding library requested by the user */ 
    7043#if defined HAVE_PLPA 
    7144    if (!strcmp(HYDT_bind_info.bindlib, "plpa")) { 
     
    8255#endif /* HAVE_HWLOC */ 
    8356 
    84     if (HYDT_bind_info.support_level != HYDT_BIND_NONE) { 
    85         HYDU_MALLOC(HYDT_bind_info.bindmap, int *, HYDT_bind_info.num_procs * sizeof(int), 
    86                     status); 
    87  
    88         for (i = 0; i < HYDT_bind_info.num_procs; i++) { 
    89  
    90             /* RR is supported at the basic binding level */ 
    91             if (!strcmp(binding, "rr")) { 
    92                 HYDT_bind_info.bindmap[i] = i; 
    93                 continue; 
    94             } 
    95  
    96             /* If we reached here, the user requested for topology 
    97              * aware binding. */ 
    98             if (HYDT_bind_info.support_level != HYDT_BIND_TOPO) 
    99                 HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, 
    100                                     "topology binding not supported on this platform\n"); 
    101  
    102             if (!strcmp(binding, "buddy")) { 
    103                 thread = i / (HYDT_bind_info.num_sockets * HYDT_bind_info.num_cores); 
    104  
    105                 core = i % (HYDT_bind_info.num_sockets * HYDT_bind_info.num_cores); 
    106                 core /= HYDT_bind_info.num_sockets; 
    107  
    108                 sock = i % HYDT_bind_info.num_sockets; 
    109             } 
    110             else if (!strcmp(binding, "pack")) { 
    111                 sock = i / (HYDT_bind_info.num_cores * HYDT_bind_info.num_threads); 
    112  
    113                 core = i % (HYDT_bind_info.num_cores * HYDT_bind_info.num_threads); 
    114                 core /= HYDT_bind_info.num_threads; 
    115  
    116                 thread = i % HYDT_bind_info.num_threads; 
    117             } 
    118             else { 
    119                 HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unknown binding option\n"); 
    120             } 
    121  
    122             for (j = 0; j < HYDT_bind_info.num_procs; j++) { 
    123                 if (HYDT_bind_info.topology[j].socket_rank == sock && 
    124                     HYDT_bind_info.topology[j].core_rank == core && 
    125                     HYDT_bind_info.topology[j].thread_rank == thread) { 
    126                     HYDT_bind_info.bindmap[i] = HYDT_bind_info.topology[j].processor_id; 
    127                     break; 
    128                 } 
    129             } 
    130         } 
    131     } 
    132     else { 
    133         /* If no binding is supported, we just set all mappings to -1 */ 
     57    /* If we are not able to initialize the binding library, we set 
     58     * all mappings to -1 */ 
     59    if (HYDT_bind_info.support_level == HYDT_BIND_NONE) { 
    13460        HYDU_MALLOC(HYDT_bind_info.bindmap, int *, sizeof(int), status); 
    13561        HYDT_bind_info.num_procs = 1; 
    13662        HYDT_bind_info.bindmap[0] = -1; 
     63 
     64        goto fn_exit; 
     65    } 
     66 
     67    if (!strncmp(binding, "user:", strlen("user:"))) { 
     68        /* If the user specified the binding, we don't need to 
     69         * initialize anything */ 
     70 
     71        /* Find the number of processing elements */ 
     72        bindstr = HYDU_strdup(binding + strlen("user:")); 
     73        HYDT_bind_info.num_procs = 0; 
     74        bindentry = strtok(bindstr, ","); 
     75        while (bindentry) { 
     76            HYDT_bind_info.num_procs++; 
     77            bindentry = strtok(NULL, ","); 
     78        } 
     79 
     80        /* Find the actual processing elements */ 
     81        HYDU_MALLOC(HYDT_bind_info.bindmap, int *, HYDT_bind_info.num_procs * sizeof(int), 
     82                    status); 
     83        i = 0; 
     84        bindstr = HYDU_strdup(binding + strlen("user:")); 
     85        bindentry = strtok(bindstr, ","); 
     86        while (bindentry) { 
     87            HYDT_bind_info.bindmap[i++] = atoi(bindentry); 
     88            bindentry = strtok(NULL, ","); 
     89        } 
     90 
     91        goto fn_exit; 
     92    } 
     93 
     94    HYDU_MALLOC(HYDT_bind_info.bindmap, int *, HYDT_bind_info.num_procs * sizeof(int), 
     95                status); 
     96 
     97    for (i = 0; i < HYDT_bind_info.num_procs; i++) { 
     98 
     99        /* RR is supported at the basic binding level */ 
     100        if (!strcmp(binding, "rr")) { 
     101            HYDT_bind_info.bindmap[i] = i; 
     102            continue; 
     103        } 
     104 
     105        /* If we reached here, the user requested for topology aware 
     106         * binding. */ 
     107        if (HYDT_bind_info.support_level != HYDT_BIND_TOPO) 
     108            HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, 
     109                                "topology binding not supported on this platform\n"); 
     110 
     111        if (!strcmp(binding, "buddy")) { 
     112            thread = i / (HYDT_bind_info.num_sockets * HYDT_bind_info.num_cores); 
     113 
     114            core = i % (HYDT_bind_info.num_sockets * HYDT_bind_info.num_cores); 
     115            core /= HYDT_bind_info.num_sockets; 
     116 
     117            sock = i % HYDT_bind_info.num_sockets; 
     118        } 
     119        else if (!strcmp(binding, "pack")) { 
     120            sock = i / (HYDT_bind_info.num_cores * HYDT_bind_info.num_threads); 
     121 
     122            core = i % (HYDT_bind_info.num_cores * HYDT_bind_info.num_threads); 
     123            core /= HYDT_bind_info.num_threads; 
     124 
     125            thread = i % HYDT_bind_info.num_threads; 
     126        } 
     127        else { 
     128            HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unknown binding option\n"); 
     129        } 
     130 
     131        for (j = 0; j < HYDT_bind_info.num_procs; j++) { 
     132            if (HYDT_bind_info.topology[j].socket_rank == sock && 
     133                HYDT_bind_info.topology[j].core_rank == core && 
     134                HYDT_bind_info.topology[j].thread_rank == thread) { 
     135                HYDT_bind_info.bindmap[i] = HYDT_bind_info.topology[j].processor_id; 
     136                break; 
     137            } 
     138        } 
    137139    } 
    138140