src/model_mapping.c
//#define VERIFY_MAPPING 1 //useful for debugging
//This function maps LPs to KPs on PEs and is called at the start
//This example is the same as Linear Mapping
define VERIFY_MAPPING 1 //useful for debugging
This function maps LPs to KPs on PEs and is called at the start
This example is the same as Linear Mapping
define VERIFY_MAPPING 1 // useful for debugging This function maps LPs to KPs on PEs and is called at the start This example is the same as Linear Mapping
void model_custom_mapping_linear(void){
    unsigned int nlp_per_kp;
    tw_lpid  lpid;
    tw_kpid  kpid;
    unsigned int j;
    nlp_per_kp = (int)ceil((double) g_tw_nlp / (double) g_tw_nkp);
    if(!nlp_per_kp) {
        tw_error(TW_LOC, "Not enough KPs defined: %d", g_tw_nkp);
    }
    g_tw_lp_offset = g_tw_mynode * g_tw_nlp;
#if VERIFY_MAPPING
    fprintf(node_out_file, "NODE %lu: nlp %lu, offset %lu\n", g_tw_mynode, g_tw_nlp, g_tw_lp_offset);
    fprintf(node_out_file, "\tPE %lu\n", g_tw_pe->id);
#endif
    for(kpid = 0, lpid = 0; kpid < nkp_per_pe; kpid++) {
        tw_kp_onpe(kpid, g_tw_pe);
#if VERIFY_MAPPING
        fprintf(node_out_file, "\t\tKP %lu", kpid);
#endif
        for(j = 0; j < nlp_per_kp && lpid < g_tw_nlp; j++, lpid++) {
            tw_lp_onpe(lpid, g_tw_pe, g_tw_lp_offset+lpid);
            tw_lp_onkp(g_tw_lp[lpid], g_tw_kp[kpid]);
#if VERIFY_MAPPING
            if(0 == j % 20) {
                fprintf(node_out_file, "\n\t\t\t");
            }
            fprintf(node_out_file, "%lu ", lpid+g_tw_lp_offset);
#endif
        }
#if VERIFY_MAPPING
        fprintf(node_out_file, "\n");
#endif
    }
    if(!g_tw_lp[g_tw_nlp-1]) {
        tw_error(TW_LOC, "Not all LPs defined! (g_tw_nlp=%d)", g_tw_nlp);
    }
    if(g_tw_lp[g_tw_nlp-1]->gid != g_tw_lp_offset + g_tw_nlp - 1) {
        tw_error(TW_LOC, "LPs not sequentially enumerated!");
    }
}
void model_custom_mapping_linear ( void ) { unsigned int nlp_per_kp ; tw_lpid lpid ; tw_kpid kpid ; unsigned int j ; nlp_per_kp = ( int ) ceil ( ( double ) g_tw_nlp / ( double ) g_tw_nkp ) ; if ( ! nlp_per_kp ) { tw_error ( TW_LOC , " " , g_tw_nkp ) ; } g_tw_lp_offset = g_tw_mynode * g_tw_nlp ; #if VERIFY_MAPPING fprintf ( node_out_file , " \n " , g_tw_mynode , g_tw_nlp , g_tw_lp_offset ) ; fprintf ( node_out_file , " \t \n " , g_tw_pe -> id ) ; #endif for ( kpid = 0 , lpid = 0 ; kpid < nkp_per_pe ; kpid ++ ) { tw_kp_onpe ( kpid , g_tw_pe ) ; #if VERIFY_MAPPING fprintf ( node_out_file , " \t \t " , kpid ) ; #endif for ( j = 0 ; j < nlp_per_kp && lpid < g_tw_nlp ; j ++ , lpid ++ ) { tw_lp_onpe ( lpid , g_tw_pe , g_tw_lp_offset + lpid ) ; tw_lp_onkp ( g_tw_lp [ lpid ] , g_tw_kp [ kpid ] ) ; #if VERIFY_MAPPING if ( 0 == j % 20 ) { fprintf ( node_out_file , " \n \t \t \t " ) ; } fprintf ( node_out_file , " " , lpid + g_tw_lp_offset ) ; #endif } #if VERIFY_MAPPING fprintf ( node_out_file , " \n " ) ; #endif } if ( ! g_tw_lp [ g_tw_nlp - 1 ] ) { tw_error ( TW_LOC , " " , g_tw_nlp ) ; } if ( g_tw_lp [ g_tw_nlp - 1 ] -> gid != g_tw_lp_offset + g_tw_nlp - 1 ) { tw_error ( TW_LOC , " " ) ; } }
define VERIFY_MAPPING 1 //useful for debugging
This function maps LPs to KPs on PEs and is called at the start
This example is the same as Linear Mapping
define VERIFY_MAPPING 1 // useful for debugging This function maps LPs to KPs on PEs and is called at the start This example is the same as Linear Mapping
// may end up wasting last KP, but guaranteed each KP has == nLPs