void PT::vec_cb_norm(int n, IFloat **vout, IFloat **vin, const int *dir,int parity, IFloat * gauge) { //List of the different directions int wire[n]; int i; // int j,d,s,k; //SCUDirArgs for sending and receiving in the n directions SCUDirArgIR *SCUarg_p[2*non_local_dirs]; //SCUDirArgIR *SCUarg_p[2*n]; SCUDirArgMulti SCUmulti; static int call_num = 0; int vlen = VECT_LEN; int vlen2 = VECT_LEN; // printf("gauge=%p\n",gauge); call_num++; //Name our function // char *fname="pt_1vec_cb_norm()"; //Set the transfer directions //If wire[i] is even, then we have communication in the negative direction //If wire[i] is odd, then we have communication in the positive direction for(i=0;i<n;i++) wire[i]=dir[i]; Float dtime; //If wire[i] is odd, then we have parallel transport in the //positive direction. In this case, the matrix multiplication is //done before the field is transferred over to the adjacent node // //If we have transfer in the negative T direction (wire[i] = 6) then //we have to copy the appropriate fields into the send buffer if(conjugated) for(i=0;i<n;i++) { if(!local[wire[i]/2]) { if(wire[i]%2) { //printf("dir = %d, pre-mulitply\n", wire[i]); #ifdef PROFILE dtime = - dclock(); #endif partrans_cmv(non_local_chi_cb[wire[i]]/2,uc_nl_cb_pre[parity][wire[i]/2],gauge,vin[i],snd_buf_cb[wire[i]/2]); #ifdef PROFILE dtime +=dclock(); print_flops("",fname,66*non_local_chi_cb[wire[i]],dtime); #endif } else if((wire[i] == 6)) { #ifdef PROFILE dtime = - dclock(); #endif #if 1 pt_copy_buffer(non_local_chi_cb[6],(long)vin[i],(long)snd_buf_t_cb,(long)Toffset[parity]); #else for(j = 0; j < non_local_chi_cb[6];j++) for(k = 0; k < VECT_LEN;k++) *(snd_buf_t_cb+j*VECT_LEN+k) = *(vin[i] + *(Toffset[parity]+j)+ k); //moveMem(snd_buf_t_cb + j*VECT_LEN,vin[i] + *(Toffset[parity]+j)*vlen,VECT_LEN*sizeof(IFloat)); #endif #ifdef PROFILE dtime +=dclock(); print_flops(fname,"pt_copy_buffer()",0,dtime); #endif } } } else for(i=0;i<n;i++) { if(!local[wire[i]/2]) { if(wire[i]%2) { #ifdef PROFILE dtime = - dclock(); #endif partrans_cmv_dag(non_local_chi_cb[wire[i]]/2,uc_nl_cb_pre[parity][wire[i]/2],gauge,vin[i],snd_buf_cb[wire[i]/2]); #ifdef PROFILE dtime +=dclock(); print_flops("",fname,66*non_local_chi_cb[wire[i]],dtime); #endif } else if(wire[i] == 6) { #ifdef PROFILE dtime = - dclock(); #endif #if 1 pt_copy_buffer(non_local_chi_cb[6],(long)vin[i],(long)snd_buf_t_cb,(long)Toffset[parity]); #else for(j = 0; j < non_local_chi_cb[6];j++) for(k = 0; k < VECT_LEN;k++) *(snd_buf_t_cb+j*VECT_LEN+k) = *(vin[i] + *(Toffset[parity]+j)+ k); // moveMem(snd_buf_t_cb + j*VECT_LEN,vin[i] + *(Toffset[parity]+j),VECT_LEN*sizeof(IFloat)); #endif #ifdef PROFILE dtime +=dclock(); print_flops(fname,"pt_copy_buffer()",0,dtime); #endif } } } #ifdef PROFILE dtime = - dclock(); #endif #if 1 int comms = 0; for(i=0;i<n;i++) { if(!local[wire[i]/2]) { //Calculate the starting address for the data to be sent IFloat *addr = vin[i] + VECT_LEN * offset_cb[wire[i]]; //This points to the appropriate SCUDirArg for receiving SCUarg_p[2*comms] = SCUarg_cb[2*wire[i]]; //This points to the appropriate SCUDirArg for sending SCUarg_p[2*comms+1] = SCUarg_cb[2*wire[i]+1]; //Set the send address if(wire[i]%2) SCUarg_p[2*comms+1]->Addr((void *)snd_buf_cb[wire[i]/2]); else if(wire[i] == 6) SCUarg_p[2*comms+1]->Addr((void *)snd_buf_t_cb); else SCUarg_p[2*comms+1]->Addr((void *)addr); comms++; } } #endif if(comms){ SCUmulti.Init(SCUarg_p,2*comms); //Begin transmission SCUmulti.SlowStartTrans(); } //Do local calculations if(conjugated) { for(i=0;i<n;i++) { #ifdef PROFILE dtime = - dclock(); #endif if(wire[i]%2) partrans_cmv(local_chi_cb[wire[i]]/2,uc_l_cb[parity][wire[i]],gauge,vin[i],vout[i]); else partrans_cmv_dag(local_chi_cb[wire[i]]/2,uc_l_cb[parity][wire[i]],gauge,vin[i],vout[i]); #ifdef PROFILE dtime +=dclock(); print_flops("",fname,66*local_chi_cb[wire[i]],dtime); #endif } } else { for(i=0;i<n;i++) { #ifdef PROFILE dtime = - dclock(); #endif if(!(wire[i]%2)) partrans_cmv(local_chi_cb[wire[i]]/2,uc_l_cb[parity][wire[i]],gauge,vin[i],vout[i]); else partrans_cmv_dag(local_chi_cb[wire[i]]/2,uc_l_cb[parity][wire[i]],gauge,vin[i],vout[i]); #ifdef PROFILE dtime +=dclock(); print_flops("",fname,66*local_chi_cb[wire[i]],dtime); #endif } } //End transmission if(comms){ SCUmulti.TransComplete(); } //If wire[i] is even, then we have transport in the negative direction. //In this case, the vector field is multiplied by the SU(3) link matrix //after all communication is complete IFloat *fp0, *fp1; for(i=0;i<n;i++) { if(!local[wire[i]/2]) { if(!(wire[i]%2)) { #ifdef PROFILE dtime = - dclock(); #endif if(conjugated) partrans_cmv_dag(non_local_chi_cb[wire[i]]/2,uc_nl_cb[parity][wire[i]],gauge,rcv_buf[wire[i]],vout[i]); else partrans_cmv(non_local_chi_cb[wire[i]]/2,uc_nl_cb[parity][wire[i]],gauge,rcv_buf[wire[i]],vout[i]); #ifdef PROFILE dtime +=dclock(); print_flops("",fname,66*non_local_chi_cb[wire[i]],dtime); #endif } //Otherwise we have parallel transport in the positive direction. //In this case, the received data has already been pre-multiplied //All we need to do is to put the transported field in the correct place else { #ifdef PROFILE dtime = - dclock(); #endif #if 1 pt_copy(non_local_chi_cb[wire[i]]/2,uc_nl_cb[parity][wire[i]],rcv_buf[wire[i]],vout[i]); #else //Place the data in the receive buffer into the result vector for(s=0;s<non_local_chi_cb[wire[i]];s++) { fp0 = (IFloat *)((long)rcv_buf[wire[i]]+uc_nl_cb[parity][wire[i]][s].src); fp1 = (IFloat *)((long)vout[i]+uc_nl_cb[parity][wire[i]][s].dest); for(d = 0;d<VECT_LEN;d++) *(fp1+d) = *(fp0+d); //moveMem(fp1,fp0,VECT_LEN*sizeof(IFloat)); } #endif #ifdef PROFILE dtime +=dclock(); print_flops(fname,"pt_copy()",0,dtime); #endif } } } // ParTrans::PTflops +=33*n*vol; }
/*! Take a top-object parse-tree (pt0), and expand all tree references one level. * * One level only. Parse-tree is expanded itself (not copy). * * @param[in] h Handle needed to resolve tree-references (\@tree) * @param[in] coprev Parent, if any * @param[in,out] pt0 parse-tree to expand. In: original, out: expanded * @note The loop may need to suboptimal iterations since after every time you * find a tree reference, you add new elements to the list and re-iterates * from start. Since the expanded elements may be references,... * @see pt_expand_treeref_cleanup */ int pt_expand_treeref(cligen_handle h, cg_obj *coprev, parse_tree *pt0) { int i, k; cg_obj *co; parse_tree *ptref; /* tree referenced by pt0 orig */ parse_tree pt1ref = {0, }; /* tree referenced by pt0 resolved */ cg_obj *cot; /* treeref object */ char *treename; cg_obj *coprev2; if (pt0->pt_vec == NULL) return 0; again: for (i=0; i<pt0->pt_len; i++){ /* */ if ((co = pt0->pt_vec[i]) == NULL) continue; /* XXX remove reference */ if (co->co_type == CO_REFERENCE && !co->co_refdone){ /* Expansion is made in-line so we need to know if already expanded */ treename = co->co_command; /* Find the referring tree */ if ((ptref = cligen_tree_find(h, treename)) == NULL){ fprintf(stderr, "CLIgen subtree '%s' not found\n", treename); return -1; } /* make a copy of ptref -> pt1ref */ coprev2 = co_up(co); if (pt_copy(*ptref, coprev2, &pt1ref) < 0){ /* From ptref -> pt1ref */ fprintf(stderr, "%s: Copying parse-tree\n", __FUNCTION__); return -1; } /* Recursively add extra NULLs in non-terminals */ if (co->co_hide && /* XXX: hide to trunk? */ pt_reference_trunc(pt1ref) < 0) return -1; /* Recursively install callback all through the referenced tree */ if (co->co_callbacks && pt_callback_reference(pt1ref, co->co_callbacks) < 0) return -1; /* Copy top-levels into original parse-tree */ for (k=0; k<pt1ref.pt_len; k++) if ((cot = pt1ref.pt_vec[k]) != NULL){ cot->co_treeref++; /* Mark as expanded referenced tree */ if (co_insert(pt0, cot) == NULL) /* XXX alphabetically */ return -1; } /* Due to loop above, all co in vec should be moved, it should be safe to remove */ free(pt1ref.pt_vec); if (coprev && coprev->co_ref) /* coprev2 ? */ coprev->co_ref->co_pt = coprev->co_pt; co->co_refdone = 1; goto again; } } return 0; }
/* Merge and validate the PrintTicket part according to the current scope. */ Bool pt_mandv( /*@in@*/ /*@notnull@*/ xmlGFilter* filter, /*@in@*/ /*@notnull@*/ XPS_PT* pt, /*@in@*/ /*@notnull@*/ xps_partname_t* part) { Bool status; OBJECT part_file = OBJECT_NOTVM_NOTHING; uint8* pt_uri; uint32 pt_uri_len; xmlGIStr *pt_mimetype ; static XPS_CONTENT_TYPES pt_content_types[] = { { XML_INTERN(mimetype_printing_printticket) }, XPS_CONTENT_TYPES_END } ; HQASSERT((pt != NULL), "pt_mandv: state pointer NULL"); HQASSERT((pt->device == NULL || (pt->scope >= PT_SCOPE_JOB && pt->scope <= PT_SCOPE_PAGE)), "pt_mandv: PT has invalid scope"); /* Catch absence of any PT device */ if ( pt->device == NULL ) { return TRUE ; } /* Open a PS file on the PrintTicket part for read. */ if ( !xps_open_file_from_partname(filter, part, &part_file, XML_INTERN(rel_xps_2005_06_printticket), pt_content_types, &pt_mimetype, FALSE)) { return FALSE ; } status = FALSE; /* Open the scope start file and copy the print ticket part contents to it. * Note: the scope start file gets closed by reading back the PS config and * that this will happen before the next print ticket is seen. */ if ( pt_open_config_file(pt, (uint8*)"S", SW_RDWR, RW_FLAG, &pt->scope_file) ) { status = pt_copy(oFile(part_file), oFile(pt->scope_file)); if ( !status ) { pt_close_start_file(pt); if ( !hqn_uri_get_field(part->uri, &pt_uri, &pt_uri_len, HQN_URI_NAME)) { HQFAIL("Unable to get PT URI") ; pt_uri_len = 0; } (void)pt_error_handler(pt, pt_uri, pt_uri_len); } } /* Failure reading from the PT part will have already been caught so don't * really care what happens when closing here. */ (void)xml_file_close(&part_file); return status ; } /* pt_mandv */