static int q_I_get(lua_State *L) { switch (qlua_qtype(L, 2)) { case qTable: { mLatInt *V = qlua_checkLatInt(L, 1, NULL); mLattice *S = qlua_ObjLattice(L, 1); QLA_Int *locked; int *idx = 0; int z; idx = qlua_checklatcoord(L, 2, S); CALL_QDP(L); locked = QDP_expose_I(V->ptr); int site_node = QDP_node_number_L(S->lat, idx); if (site_node == QDP_this_node) { z = QLA_elem_I(locked[QDP_index_L(S->lat, idx)]); } QDP_reset_I(V->ptr); qlua_free(L, idx); XMP_dist_int_array(site_node, 1, &z); lua_pushnumber(L, z); return 1; } case qString: return qlua_selflookup(L, 1, luaL_checkstring(L, 2)); default: break; } return qlua_badindex(L, "Int"); }
static int q_I_put(lua_State *L) { mLatInt *V = qlua_checkLatInt(L, 1, NULL); mLattice *S = qlua_ObjLattice(L, 1); QLA_Int *locked; int *idx = 0; int z = luaL_checkint(L, 3); idx = qlua_checklatcoord(L, 2, S); CALL_QDP(L); locked = QDP_expose_I(V->ptr); if (QDP_node_number_L(S->lat, idx) == QDP_this_node) { QLA_elem_I(locked[QDP_index_L(S->lat, idx)]) = z; } QDP_reset_I(V->ptr); qlua_free(L, idx); return 0; }
void fromQDP_F(real *yy, Layout *l, real *xx, QDP_Lattice *lat, int nelem, int swap) { int nd = l->nDim; int nl = l->nSitesInner; int ysize = nelem * nl; //double n2=0; int nsites = l->nSites; if(nsites!=QDP_sites_on_node_L(lat)) { printf("%s: nsites(%i) != QDP_sites_on_node_L(lat)(%i)\n", __func__, nsites, QDP_sites_on_node_L(lat)); QDP_abort(-1); } for(int j=0; j<nsites; j++) { // qll sites int x[nd]; LayoutIndex li; li.rank = myrank; li.index = j; layoutCoord(l, x, &li); int r = QDP_node_number_L(lat, x); if(r==QDP_this_node) { int i = QDP_index_L(lat, x); int oi = j / l->nSitesInner; int ii = j % l->nSitesInner; real *yi = yy + (ysize*oi + ii); for(int e=0; e<nelem; e++) { int e2 = e/2; int ei = e2 % swap; int eo = e2 / swap; int es = ei*(nelem/swap) + eo*2 + (e&1); yi[nl*e] = xx[i*nelem+es]; //n2 += er*er + ei*ei; } } else { printf("unpack: site on wrong node!\n"); QDP_abort(-1); } } //printf("unpack2: %g\n", n2); }