-
Notifications
You must be signed in to change notification settings - Fork 2
/
gates-map.c
66 lines (54 loc) · 1.73 KB
/
gates-map.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <assert.h>
#include "generic-model.h"
#include "routing.h"
//#define VERIFY_MAPPING 1
tw_peid gates_custom_mapping_to_pe(tw_lpid gid){
assert(gid < routing_table_lp[RO_TOTAL]);
int i;
for (i = 0; i < tw_nnodes(); i++) {
if (gid < (*routing_table_mpi)[i+1]) {
return i;
}
}
tw_error(TW_LOC, "ERROR: can't map gid %llu to a PE", gid);
}
void gates_custom_mapping_setup(void){
tw_pe *pe;
int kpid;
int lpgid, lplid;
int j;
//PARTS MAPPING
int extra_kps = g_tw_nlp - (g_tw_nkp * LPS_PER_KP);
#if VERIFY_MAPPING
printf("Node %ld: nlp %llu, offset %llu, extra_kps %d\n", g_tw_mynode, g_tw_nlp, g_tw_lp_offset, extra_kps);
#endif
//This loop happens once on each pe
//set starting local and global ids for the LPs on this node
for (lplid = 0, lpgid = g_tw_lp_offset, pe = NULL; (pe = tw_pe_next(pe)); ) {
//For each kp
for (kpid = 0; kpid < g_tw_nkp; kpid++) {
tw_kp_onpe(kpid, pe);
//lps on this particular kp
int nlps = LPS_PER_KP;
if (kpid < extra_kps) {
nlps++;
}
for (j = 0; j < nlps; j++, lpgid++, lplid++) {
tw_lp_onpe(lplid, pe, lpgid);
tw_lp_onkp(g_tw_lp[lplid], g_tw_kp[kpid]);
#if VERIFY_MAPPING
if (0 == j) {
printf("PE %lu\tKP %d\tLP %d\n", pe->id, kpid, lpgid);
}
#endif
}
}
}
}
tw_lp * gates_custom_mapping_to_local(tw_lpid gid){
assert(gid < routing_table_lp[RO_TOTAL]);
assert(gid >= (*routing_table_mpi)[g_tw_mynode]);
assert(gid < (*routing_table_mpi)[g_tw_mynode+1]);
int id = gid - g_tw_lp_offset;
return g_tw_lp[id];
}