#include #include #include ti_LOCAL_ARRAY ti_cast_to_local(const char *where, const ti_GLOBAL_ARRAY *g) { ti_LOCAL_ARRAY l; #ifdef MEMORY_DISTRIBUTED if (PREDICT_FALSE(!isLocal(g->A))) { fprintf(stderr, "Attempt to cast global array to local " "on processor %d failed at %s\n", MYPROC, where); assert(0); exit(-3); } #endif #if DUMPABLE_ARRAYS l.dumpfn = g->dumpfn; #endif l.domain = g->domain; memcpy(l.stride, g->stride, sizeof(l.stride)); memcpy(l.base, g->base, sizeof(l.base)); memcpy(l.sideFactors, g->sideFactors, sizeof(l.sideFactors)); l.A = TO_LOCAL(g->A); l.ancestor = TO_LOCAL(g->ancestor); l.where = g->where; #if EXPLICITLY_STORE_CREATOR l.creator = g->creator; #endif return l; } ti_GLOBAL_ARRAY ti_cast_to_global(const ti_LOCAL_ARRAY *l, int box) { ti_GLOBAL_ARRAY g; #if DUMPABLE_ARRAYS g.dumpfn = l->dumpfn; #endif g.domain = l->domain; memcpy(g.stride, l->stride, sizeof(g.stride)); memcpy(g.base, l->base, sizeof(g.base)); memcpy(g.sideFactors, l->sideFactors, sizeof(g.sideFactors)); TO_GLOBALB(g.A, box, l->A); TO_GLOBALB(g.ancestor, box, l->ancestor); g.where = l->where; #if EXPLICITLY_STORE_CREATOR g.creator = l->creator; #endif return g; }