void printMatrixFloat(int matid) { float m[16]; #define SV(N) \ asm("usv.q R"#N"00, 0 + %0\n" \ "usv.q R"#N"01, 16 + %0\n" \ "usv.q R"#N"02, 32 + %0\n" \ "usv.q R"#N"03, 48 + %0\n" \ : "=m"(m)) switch (matid) { case 0: SV(0); break; case 1: SV(1); break; case 2: SV(2); break; case 3: SV(3); break; case 4: SV(4); break; case 5: SV(5); break; case 6: SV(6); break; case 7: SV(7); break; } printf("\n\n"); printf(" C%d00 C%d10 C%d20 C%d30\n", matid, matid, matid, matid); printf("R%d00: %0.6f %0.6f %0.6f %0.6f\n", matid, m[0], m[1], m[2], m[3]); printf("R%d01: %0.6f %0.6f %0.6f %0.6f\n", matid, m[4], m[5], m[6], m[7]); printf("R%d02: %0.6f %0.6f %0.6f %0.6f\n", matid, m[8], m[9], m[10], m[11]); printf("R%d03: %0.6f %0.6f %0.6f %0.6f\n", matid, m[12], m[13], m[14], m[15]); }
//用于检查prb_bitmap是否有剩余资源,prb_bitmap2、prb_bitmap7; //目前资源分配的原则是顺序分配,即如果发现某个prb_bitmap位不等于0,则代表后面的资源均未被分配。 //输入:cqi,mac层bitmap映射物理层,但是不同的终端的cqi不同则调制方式可能不同,从而导致每个prb可以承载的数据量不同 static int Cal_usable_ResOfBitmap(u16 cqi,u16 subframe) { int i,remain_res,idle_bit2,idle_bit7; FIN(Cal_usable_ResOfBitmap()); SV_PTR_GET(mac_sv); idle_bit2=idle_bit7=0;//如果bitmap2和7均无剩余位,则函数返回0. if(subframe==2) { for(i=0;i<100;i++) { if(0==SV(next_prb_bitmap2[i])) { idle_bit2=100-i; break; } } for(i=0;i<100;i++) { if(0==SV(prb_bitmap7[i])) { idle_bit7=100-i; break; } } } if(subframe==7) { for(i=0;i<100;i++) { if(0==SV(next_prb_bitmap2[i])) { idle_bit2=100-i; break; } } for(i=0;i<100;i++) { if(0==SV(next_prb_bitmap7[i])) { idle_bit7=100-i; break; } } } remain_res=Get_Ul_PerPrb_Datasize(cqi) * (idle_bit2 + idle_bit7); FRET(remain_res); }
void delete_overtime_tc_rnti() { int i; FIN(delete_overtime_tc_rnti()); SV_PTR_GET(mac_sv); //重新启动定时器 fsm_schedule_self(2000000 , TC_RNTI_CHECK_TIMER); for(i=0;i<NUM_RNTI;i++) { if( SV(tc_rnti_notes[i])== 1 && SV(rntiarray[i].Type_rnti)==TC_RNTI)//20ms过后,如果存在TC-RNTI且其tcrnti的记录表记录为有tc-rnti SV(rntiarray[i].Type_rnti) = UNALLOCATED_RNTI; } note_tc_rnti();//重新记录TC-RNTI状态 FOUT; }
//清空prb_bitmap函数。 //20141018改 void Reset_Prb_Bitmap() { int i; FIN(Reset_Prb_Bitmap()); SV_PTR_GET(mac_sv); for(i=0;i<100;i++) { SV(prb_bitmap7[i])=SV(next_prb_bitmap7[i]); SV(next_prb_bitmap7[i])=0; SV(next_prb_bitmap2[i])=0; } FOUT; }
//回收分配出去的rnti值 static void recall_rnti(u16 receive_rnti) { int i; FIN(recall_tc_rnti()); SV_PTR_GET(mac_sv); for(i=0;i<NUM_RNTI;i++) { if(receive_rnti==SV(rntiarray[i]).m_rnti) { SV(rntiarray[i]).Type_rnti=UNALLOCATED_RNTI; } } FOUT; }
/************************************************************************************************************************************************ **Function name:send_rrc_connection_release_msg_to_ue **Desciption:use for testing ,generated rrcConnectionRelease info **Input : **Output:generated rrcConnectionRelease info ,and stored in the global variable. **Created by:zhou yang **Created Date:2014/09/08 **-------------------------------------------------------------------------------------------------- **Modified by:zhou yang **Modified Date:2014/10/07 **Descriptions:modified format **-------------------------------------------------------------------------------------------------- *************************************************************************************************************************************************/ void send_rrc_connection_release_msg_to_ue() { SV_PTR_GET(rrc_sv_enb_ue); char *msg=NULL; int msg_len; int message_type; struct RRCConnectionRelease rrcConnectionRelease ; struct DL_DCCH_Message *dl_dcch_message; FIN(send_rrc_connection_release_msg_to_ue()); fsm_printf("[rrc] [conn_release] send_rrc_connection_release_msg_to_ue().\n"); dl_dcch_message=(struct DL_DCCH_Message *)fsm_mem_alloc(sizeof(struct DL_DCCH_Message )); rrcConnectionRelease.rrcTransactionIdentifier=1; rrcConnectionRelease.haveIdleModeMobilityControlInfo=true; rrcConnectionRelease.releaseCause=other; rrcConnectionRelease.idleModeMobilityControlInfo.have_t320=true; rrcConnectionRelease.idleModeMobilityControlInfo.t320_Value=min5; rrcConnectionRelease.idleModeMobilityControlInfo.haveCellReselectionPriorityInfo=false; dl_dcch_message->msg.rrcConnectionRelease=rrcConnectionRelease; dl_dcch_message->type=2; msg=(char*)dl_dcch_message; msg_len=sizeof(struct RRCConnectionRelease); message_type=4; //fsm_octets_print(msg, msg_len); packet_send_to_rlc(msg, msg_len, message_type, SV(crnti)); //fsm_mem_free(rrcConnectionRelease); //rrcConnectionRelease=NULL; FOUT; }
TF1 *GausBF::GetDf(Int_t is1, Int_t is9, Double_t rgt) const { AMSPoint p1 = GetP1(is1); AMSPoint p9 = GetP9(is9); AMSPoint pnt = p1; AMSDir dir = p9-p1; TString str = "[1]+1/[2]*TMath::C()/1e12*(0"; for (Int_t i = 0; i < 12; i++) str += SV(i*3+3); str += ")"; static TF1 *func = 0; if (!func) func = new TF1("fdf", str); func->FixParameter(0, 0); func->FixParameter(1, dir.y()/dir.z()); func->FixParameter(2, rgt); for (Int_t i = 0; i < Np; i++) { Double_t par = GetPar(is1, is9, i); if (par != 0 && (i < 3 || i%3 == 0)) func->SetParameter(i+3, par); else func->FixParameter(i+3, par); } return func; }
//函数能够将bsr的大小和物理层上传的数据,增加到S_UEinfo的队列中。 void Add_sueinfo_Node(PHYtoMAC_Info *temp, int m_bsr, int type_bsr) { struct S_UEinfo * p_ul_UEinfo; FIN(Add_sueinfo_Node()); SV_PTR_GET(mac_sv); p_ul_UEinfo=(S_UEinfo *)fsm_mem_alloc(sizeof(S_UEinfo)); while(p_ul_UEinfo==NULL)//申请内存失败 p_ul_UEinfo=(S_UEinfo *)fsm_mem_alloc(sizeof(S_UEinfo)); p_ul_UEinfo->datasizeof_bsr =cal_bsrsize(m_bsr,type_bsr); p_ul_UEinfo->rnti =temp->rnti; p_ul_UEinfo->cqi =temp->cqi; p_ul_UEinfo->crc =temp->crc; p_ul_UEinfo->harqindex =temp->harqindex; //p_ul_UEinfo->pgtype =temp->pgtype; p_ul_UEinfo->pmi =temp->pmi; p_ul_UEinfo->sfn =temp->sfn; p_ul_UEinfo->sr =temp->sr; p_ul_UEinfo->subframeN =temp->subframeN; p_ul_UEinfo->ta =temp->ta; fsm_printf("###BSR_SIZE is:%d",p_ul_UEinfo->datasizeof_bsr); insert_ULschedQue(SV(ULschedQue_p), p_ul_UEinfo); //test_code Geng fsm_printf("\n###finsh inser node!\n"); FOUT; }
SV AV::remove( int index ){ void* c_sv_ptr = Perl_av_delete( my_perl, (old_AV_ptr)m_c_av_ptr, index, 0 ); return SV( c_sv_ptr, 0 ); }
//记录C-RNTI,TC-RNTI->C-RNTI void convert_TcRntiToCRnti(u16 receive_rnti) { int i; FIN(convert_TcRntiToCRnti()); SV_PTR_GET(mac_sv); for(i=0;i<NUM_RNTI;i++) { if(receive_rnti==SV(rntiarray[i]).m_rnti) { SV(rntiarray[i]).Type_rnti=C_RNTI; } } FOUT; }
static unsigned short DoAllocate_Rnti(int m_type_rnti) { int i; FIN(DoAllocate_Rnti()); SV_PTR_GET(mac_sv); for(i=5;i<NUM_RNTI;i++) { //07、30加,耿灿锡,目前仅考虑了分配TC-RNTI的情况,所以&&了tc-ranti的标记数组,防止在20ms内同一个rnti值被重复分配,引起tc-rnti定时清除的错误 if(UNALLOCATED_RNTI==SV(rntiarray[i]).Type_rnti && SV(tc_rnti_notes[i])!=1) { SV(rntiarray[i]).Type_rnti=m_type_rnti; break; } } FRET(SV(rntiarray[i]).m_rnti); }
//0x003D-0041 0x0042-0104 //rnti数组初始化,尽早执行.目前只取NUM_RNTI个rnti,以后可扩展 void init_rnti_array_val() { int i; FIN(init_rnti_array_val()); SV_PTR_GET(mac_sv); for(i=0;i<NUM_RNTI;i++) { SV(rntiarray[i].m_rnti) = i+61;//20141017耿灿锡改:和下行固定的rnti值分开,从66-265 SV(rntiarray[i].Type_rnti) = UNALLOCATED_RNTI; SV(tc_rnti_notes[i])= 0;//初始化tcrnti的记录表 } SV(RAR_receive_crnti)=0;//初始化CRNTI控制单元的标识 fsm_schedule_self(2000000 , TC_RNTI_CHECK_TIMER);//创建事件,时间设定为20ms,目的:分配TC-RNTI时刻起,20s内TC-RNTI必须被处理,否则TC-RNTI收回 FOUT; }
static int sdl_hidd_expunge(LIBBASETYPEPTR LIBBASE) { D(bug("[sdl] hidd expunge\n")); if (LIBBASE->sdl_handle) SV(SDL_Quit); return TRUE; }
//根据rnti的值,返回该rnti值对应的bitmap,以产生DCI static unsigned int Do_DlDci_bitmap(u16 rnti) { int i; u32 temp_bitmap; FIN(Do_DlDci_bitmap()); SV_PTR_GET(mac_sv); fsm_printf("[XXX]DO DL BITMAP:%d\n",rnti); for(i=0;i<DL_SCHEDULE_NUM;i++) { fsm_printf("[XXX]SCHEDULE SCHEME RNTI:%d\n",SV(schedule_scheme[i]).m_rnti); if(SV(schedule_scheme[i]).m_rnti==rnti){ fsm_printf("[XXX]DO DL BITMAP m_rbBitmap:0x%.8x\n",SV(schedule_scheme[i]).m_bitmap); temp_bitmap=(SV(schedule_scheme[i]).m_bitmap>>7);//phsical demand high->low(prb) so in order finsh 32bit->25bit,>>7 FRET(temp_bitmap); } }
int main (void) { double *x, *f, *c; int n; printf ("\nEntra la n:\n"); scanf ("%d", &n); printf ("\nEntreu les x's:\n"); x = GVM (n); printf ("\nEntreu les f's:\n"); f = GVM (n); /* Entrada necessaria */ SV (n, f); SV (n, x); difdivC (n, x, f, &c); SV (n, c); return 0; }
Lattice SV () { Lattice SV(4); SV.bond(0,1).bond(1,2).bond(2,3).bond(3,0).bond(1,3).bond(1,0,coo(1,0)).bond(2,3,coo(1,0)) .bond(1,3,coo(1,0)).bond(0,3,coo(0,-1)).bond(1,2,coo(0,-1)).bond(2,0,coo(1,1)).bond(3,1,coo(0,1)); SV.z[0]=0; SV.z[1]=.5; SV.z[2]=cpx(.5,.5); SV.z[3]=cpx(0,.5); return SV; }
void Do_Data_of_MacRarPdu_ulgrant(DATA_RAR_PDU * p_rar_pdu, struct S_RAinfo *p_ra_UEinfo,int index)//函数有问题rapid是数组? { u8 temp_prb_bitmap2[100]; u8 temp_prb_bitmap7[100]; int temp_i; FIN(Do_Data_of_MacRarPdu_ulgrant()); SV_PTR_GET(mac_sv); for(temp_i=0;temp_i<100;temp_i++) temp_prb_bitmap7[temp_i]=SV(prb_bitmap7[temp_i]); for(temp_i=0;temp_i<100;temp_i++) temp_prb_bitmap2[temp_i]=SV(next_prb_bitmap2[temp_i]); // //temp_prb_bitmap7[100]=SV(prb_bitmap7[100]);//这句话有问题,不能这么用????????????????????? //temp_prb_bitmap2[100]=SV(prb_bitmap2[100]);//20140928由于处在随机接入过程中,保存资源分配前的资源分配情况,以给多个竞争用户分配同一个资源起点的资源 p_rar_pdu->s_ulgrant.m_mcs=Do_ulgrant_mcs(p_ra_UEinfo->cqi); p_rar_pdu->s_ulgrant.m_hoppingflag=Do_ulgrant_hoppingflag(); p_rar_pdu->s_ulgrant.rb_assignment=Do_ulgrant_rb_assignment(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); if(index != 1) { for(temp_i=0;temp_i<100;temp_i++) SV(prb_bitmap7[temp_i])=temp_prb_bitmap7[temp_i]; for(temp_i=0;temp_i<100;temp_i++) SV(next_prb_bitmap2[temp_i])=temp_prb_bitmap2[temp_i]; } p_rar_pdu->s_ulgrant.m_tpc=Do_UlDci_ndi(); p_rar_pdu->s_ulgrant.m_cqiRequest=Do_ulgrant_tpc(); p_rar_pdu->s_ulgrant.m_ulDelay=Do_ulgrant_ulDelay(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); p_rar_pdu->s_ulgrant.emptybits=0; p_rar_pdu->m_bi=Do_Data_of_MacRarPdu_BI(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); p_rar_pdu->m_rapid=Do_Data_of_MacRarPdu_RAPID(p_ra_UEinfo->rapid); p_rar_pdu->m_ta=Do_Data_of_MacRarPdu_TA(p_ra_UEinfo->ta); p_rar_pdu->m_tcrnti=Do_Data_of_MacRarPdu_tcrnti(p_ra_UEinfo->rapid); fsm_printf("\n[xxx]In the function Do_Data_of_MacRarPdu_ulgrant the value of TC-RNTI is:%d\n",p_rar_pdu->m_tcrnti); FOUT; }
/************************************************************************************************************************************************ **Function name:release_radio_resource **Desciption:release all radio resource¡£ **Input : **Output:release srb drb **Created by:zhou yang **Created Date:2014/09/08 **-------------------------------------------------------------------------------------------------- **Modified by:zhou yang **Modified Date:2014/09/30 **Descriptions:modified format **-------------------------------------------------------------------------------------------------- *************************************************************************************************************************************************/ void release_radio_resource(void) { FIN(release_radio_resource()); int i; int numIndex=0; struct DrbToReleaseList drb; SV_PTR_GET(rrc_sv_enb_ue); fsm_printf("[rrc] [conn_release] release_radio_resource().\n"); for(i=0; i<maxDRB; i++) { if(enbDRBConfig[SV(uefsmid)][i]!=NULL) { drb.drbToRelease[numIndex]=enbDRBConfig[SV(uefsmid)][i]->drbIdentity; numIndex++; } } drb.num=numIndex; ApplySrbToRelease();//release SRB ApplyDrbToRelease(drb) ;//release DRB FOUT; }
int main (void) { double *x, *f; int i; x = aCy (n, -1., 1. ); SV (n, x); f = DIV (n); for (i = 0; i < n; i++) f[i] = fun (x[i]); difdiv (n, x, f); /* generat el polinomi */ writeFile (n, 0.001, -1, 1, x, f); return 0; }
void CorrectedEphemerisRange::updateCER(const Position& Rx) { relativity = svPosVel.computeRelativityCorrection() * C_MPS; svclkbias = svPosVel.clkbias * C_MPS; svclkdrift = svPosVel.clkdrift * C_MPS; cosines[0] = (Rx.X()-svPosVel.x[0])/rawrange; cosines[1] = (Rx.Y()-svPosVel.x[1])/rawrange; cosines[2] = (Rx.Z()-svPosVel.x[2])/rawrange; Position SV(svPosVel); elevation = Rx.elevation(SV); azimuth = Rx.azimuth(SV); elevationGeodetic = Rx.elevationGeodetic(SV); azimuthGeodetic = Rx.azimuthGeodetic(SV); }
ObliqueVector::ObliqueVector(integer n, integer num) { SphereVector SV(n); Element **SVs = new Element *[num]; for (integer i = 0; i < num; i++) { SVs[i] = &SV; } integer *powsintev = new integer[2]; powsintev[0] = 0; powsintev[1] = num; ProductElementInitialization(SVs, num, powsintev, 1); delete[] powsintev; delete[] SVs; };
SPDTVariable::SPDTVariable(integer dim, integer num) { SPDVariable SV(dim); Element **SVs = new Element *[num]; for (integer i = 0; i < num; i++) { SVs[i] = &SV; } integer *powsintev = new integer[2]; powsintev[0] = 0; powsintev[1] = num; ProductElementInitialization(SVs, num, powsintev, 1); delete[] powsintev; delete[] SVs; };
void CorrectedEphemerisRange::updateCER(const Position& Rx) { relativity = RelativityCorrection(svPosVel) * C_GPS_M; // relativity correction is added to dtime by the // EphemerisStore::getSatXvt routines... svclkbias = svPosVel.dtime*C_GPS_M - relativity; svclkdrift = svPosVel.ddtime * C_GPS_M; cosines[0] = (Rx.X()-svPosVel.x[0])/rawrange; cosines[1] = (Rx.Y()-svPosVel.x[1])/rawrange; cosines[2] = (Rx.Z()-svPosVel.x[2])/rawrange; Position SV(svPosVel); elevation = Rx.elevation(SV); azimuth = Rx.azimuth(SV); elevationGeodetic = Rx.elevationGeodetic(SV); azimuthGeodetic = Rx.azimuthGeodetic(SV); }
/** save configured values */ Preferences::~Preferences() { #define SV(s) setValue(#s, s) SV(console_font); SV(wrapMode); SV(console_out_fore); SV(console_out_back); SV(console_inp_fore); SV(console_inp_back); #undef SV beginWriteArray("ANSI_sequences"); for (int i = 0; i < ANSI_sequences.size(); ++i) { setArrayIndex(i); setValue("color", ANSI_sequences[i]); } endArray(); }
/******************************* * CLASS DECLARATION * *******************************/ /* Type declarations */ static char *T_initialise[] = { "editor=editor", "width=int", "height=int" }; /* Instance Variables */ static vardecl var_textMargin[] = { IV(NAME_editor, "editor", IV_GET, NAME_storage, "Editor I'm part of"), SV(NAME_gap, "size", IV_GET|IV_STORE, gapTextMargin, NAME_layout, "Distance between icons in X and Y"), SV(NAME_background, "[colour|pixmap]", IV_GET|IV_STORE, backgroundTextMargin, NAME_appearance, "Background colour") }; /* Send Methods */ static senddecl send_textMargin[] = { SM(NAME_initialise, 3, T_initialise, initialiseTextMargin, DEFAULT, "Create from editor, width and height"), SM(NAME_event, 1, "event", eventTextMargin, NAME_event, "Handle fragment-selection") }; /* Get Methods */
} /******************************* * CLASS DECLARATION * *******************************/ /* Type declarations */ static char *T_geometry[] = { "x=[int]", "y=[int]", "width=[int]", "height=[int]" }; /* Instance Variables */ static vardecl var_circle[] = { SV(NAME_fillPattern, "image|colour*", IV_GET|IV_STORE, fillPatternGraphical, NAME_appearance, "Fill pattern for internals") }; /* Send Methods */ static senddecl send_circle[] = { SM(NAME_initialise, 1, "diameter=[int]", initialiseCircle, DEFAULT, "Create circle from diameter"), SM(NAME_diameter, 1, "int", diameterCircle, NAME_area, "Set diameter"), SM(NAME_geometry, 4, T_geometry, geometryCircle, NAME_area, "Force width and height to be equal"), SM(NAME_radius, 1, "int", radiusCircle, NAME_area, "Set radius (= half diameter)"), SM(NAME_DrawPostScript, 1, "{head,body}", drawPostScriptCircle, NAME_postscript, "Create PostScript"),
void test0() { test(S(""), SV(""), 0, 0); test(S(""), SV("abcde"), 0, S::npos); test(S(""), SV("abcdeabcde"), 0, S::npos); test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos); test(S(""), SV(""), 1, 0); test(S(""), SV("abcde"), 1, S::npos); test(S(""), SV("abcdeabcde"), 1, S::npos); test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos); test(S("abcde"), SV(""), 0, 0); test(S("abcde"), SV("abcde"), 0, 0); test(S("abcde"), SV("abcdeabcde"), 0, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); test(S("abcde"), SV(""), 1, 1); test(S("abcde"), SV("abcde"), 1, 0); test(S("abcde"), SV("abcdeabcde"), 1, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); test(S("abcde"), SV(""), 2, 2); test(S("abcde"), SV("abcde"), 2, 0); test(S("abcde"), SV("abcdeabcde"), 2, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos); test(S("abcde"), SV(""), 4, 4); test(S("abcde"), SV("abcde"), 4, 0); test(S("abcde"), SV("abcdeabcde"), 4, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos); test(S("abcde"), SV(""), 5, 5); test(S("abcde"), SV("abcde"), 5, 0); test(S("abcde"), SV("abcdeabcde"), 5, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); test(S("abcde"), SV(""), 6, 5); test(S("abcde"), SV("abcde"), 6, 0); test(S("abcde"), SV("abcdeabcde"), 6, S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos); test(S("abcdeabcde"), SV(""), 0, 0); test(S("abcdeabcde"), SV("abcde"), 0, 0); test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos); test(S("abcdeabcde"), SV(""), 1, 1); test(S("abcdeabcde"), SV("abcde"), 1, 0); test(S("abcdeabcde"), SV("abcdeabcde"), 1, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos); test(S("abcdeabcde"), SV(""), 5, 5); test(S("abcdeabcde"), SV("abcde"), 5, 5); test(S("abcdeabcde"), SV("abcdeabcde"), 5, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos); test(S("abcdeabcde"), SV(""), 9, 9); test(S("abcdeabcde"), SV("abcde"), 9, 5); test(S("abcdeabcde"), SV("abcdeabcde"), 9, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos); test(S("abcdeabcde"), SV(""), 10, 10); test(S("abcdeabcde"), SV("abcde"), 10, 5); test(S("abcdeabcde"), SV("abcdeabcde"), 10, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos); test(S("abcdeabcde"), SV(""), 11, 10); test(S("abcdeabcde"), SV("abcde"), 11, 5); test(S("abcdeabcde"), SV("abcdeabcde"), 11, 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos); test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0); test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 0); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 0); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, 0); test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, 0); test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, 15); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, 0); test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, 15); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, 0); test(S("abcdeabcdeabcdeabcde"), SV(""), 21, 20); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, 15); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, 0); }
void test1() { test(S(""), SV(""), 0); test(S(""), SV("abcde"), S::npos); test(S(""), SV("abcdeabcde"), S::npos); test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos); test(S("abcde"), SV(""), 5); test(S("abcde"), SV("abcde"), 0); test(S("abcde"), SV("abcdeabcde"), S::npos); test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos); test(S("abcdeabcde"), SV(""), 10); test(S("abcdeabcde"), SV("abcde"), 5); test(S("abcdeabcde"), SV("abcdeabcde"), 0); test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos); test(S("abcdeabcdeabcdeabcde"), SV(""), 20); test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 15); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10); test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0); }
int VBX_T(vbw_vec_reverse_test)() { unsigned int aN[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 20, 25, 31, 32, 33, 35, 40, 48, 60, 61, 62, 63, 64, 64, 65, 66, 67, 68, 70, 80, 90, 99, 100, 101, 110, 128, 128, 144, 144, 160, 160, 176, 176, 192, 192, 224, 224, 256, 256, 288, 288, 320, 320, 352, 352, 384, 384, 400, 450, 512, 550, 600, 650, 700, 768, 768, 900, 900, 1023, 1024, 1200, 1400, 1600, 1800, 2048, 2048, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4096, 4096, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 6000, 7000, 8000, 8192, 8192, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 16384, 16384, 20000, 25000, 30000, 32767, 32768, 32768, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 65535, 65536, 65536 }; int retval; unsigned int N; unsigned int NBYTES; unsigned int NREPS = 100; unsigned int i,k; vbx_timestamp_t start=0,finish=0; vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP(); const unsigned int VBX_SCRATCHPAD_SIZE = this_mxp->scratchpad_size; for( i=0; i<sizeof(aN)/4; i++ ) { N = aN[i]; //printf( "testing with vector size %d\n", N ); NBYTES = sizeof(vbx_sp_t)*N; if( 2*NBYTES > VBX_SCRATCHPAD_SIZE ) continue; vbx_sp_t *vsrc = vbx_sp_malloc( NBYTES ); vbx_sp_t *vdst = vbx_sp_malloc( NBYTES ); //printf("bytes alloc: %d\n", NBYTES ); if( !vsrc ) VBX_EXIT(-1); if( !vdst ) VBX_EXIT(-1); #if ( VBX_TEMPLATE_T == BYTESIZE_DEF | VBX_TEMPLATE_T == UBYTESIZE_DEF ) unsigned int mask = 0x007F; #elif ( VBX_TEMPLATE_T == HALFSIZE_DEF | VBX_TEMPLATE_T == UHALFSIZE_DEF ) unsigned int mask = 0x7FFF; #else unsigned int mask = 0xFFFF; #endif vbx_set_vl( N ); vbx( SV(T), VMOV, vdst, -1, 0 ); // Fill the destination vector with -1 vbx( SE(T), VAND, vsrc, mask, 0 ); // Fill the source vector with enumerated values //VBX_T(print_vector)( "vsrcInit", vsrc, N ); //VBX_T(print_vector)( "vdstInit", vdst, N ); /** measure performance of function call **/ vbx_sync(); start = vbx_timestamp(); for(k=0; k<NREPS; k++ ) { retval = VBX_T(vbw_vec_reverse)( vdst, vsrc, N ); vbx_sync(); } finish = vbx_timestamp(); printf( "length %d (%s):\tvbware sp f():\t%llu", N, VBX_EXPAND_AND_QUOTE(BYTEHALFWORD), (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) ); //VBX_T(print_vector)( "vsrcPost", vsrc, N ); //VBX_T(print_vector)( "vdstPost", vdst, N ); #if VERIFY_VBWARE_ALGORITHM VBX_T(verify_vector)( vsrc, vdst, N ); #else printf(" [VERIFY OFF]"); #endif printf("\treturn value: %X", retval); vbx_set_vl( N ); vbx( SE(T), VAND, vsrc, mask, 0 ); // Reset the source vector /** measure performance of simple algorithm **/ vbx_sync(); vbx_set_vl( 1 ); vbx_set_2D( N, -sizeof(vbx_sp_t), sizeof(vbx_sp_t), 0 ); start = vbx_timestamp(); for(k=0; k<NREPS; k++ ) { vbx_2D( VV(T), VMOV, vdst+N-1, vsrc, 0 ); vbx_sync(); } finish = vbx_timestamp(); printf( "\tsimple (vl=1):\t%llu", (unsigned long long) vbx_mxp_cycles((finish-start)/NREPS) ); #if VERIFY_SIMPLE_ALGORITHM VBX_T(verify_vector)( vsrc, vdst, N ); #else printf(" [VERIFY OFF]"); #endif printf("\tcycles\n"); vbx_sp_free(); } vbx_sp_free(); printf("All tests passed successfully.\n"); return 0; }
void test0() { test(S(""), SV(""), 0, S::npos); test(S(""), SV("laenf"), 0, S::npos); test(S(""), SV("pqlnkmbdjo"), 0, S::npos); test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos); test(S(""), SV(""), 1, S::npos); test(S(""), SV("bjaht"), 1, S::npos); test(S(""), SV("hjlcmgpket"), 1, S::npos); test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos); test(S("fodgq"), SV(""), 0, S::npos); test(S("qanej"), SV("dfkap"), 0, 1); test(S("clbao"), SV("ihqrfebgad"), 0, 2); test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, 0); test(S("srdfq"), SV(""), 1, S::npos); test(S("oemth"), SV("ikcrq"), 1, S::npos); test(S("cdaih"), SV("dmajblfhsg"), 1, 1); test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, 1); test(S("cshmd"), SV(""), 2, S::npos); test(S("lhcdo"), SV("oebqi"), 2, 4); test(S("qnsoh"), SV("kojhpmbsfe"), 2, 2); test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, 2); test(S("fmtsp"), SV(""), 4, S::npos); test(S("khbpm"), SV("aobjd"), 4, S::npos); test(S("pbsji"), SV("pcbahntsje"), 4, S::npos); test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, 4); test(S("eqmpa"), SV(""), 5, S::npos); test(S("omigs"), SV("kocgb"), 5, S::npos); test(S("onmje"), SV("fbslrjiqkm"), 5, S::npos); test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos); test(S("schfa"), SV(""), 6, S::npos); test(S("igdsc"), SV("qngpd"), 6, S::npos); test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos); test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos); test(S("hcjitbfapl"), SV(""), 0, S::npos); test(S("daiprenocl"), SV("ashjd"), 0, 0); test(S("litpcfdghe"), SV("mgojkldsqh"), 0, 0); test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, 0); test(S("qpghtfbaji"), SV(""), 1, S::npos); test(S("gfshlcmdjr"), SV("nadkh"), 1, 3); test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 1); test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, 1); test(S("crnklpmegd"), SV(""), 5, S::npos); test(S("jsbtafedoc"), SV("prqgn"), 5, S::npos); test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 5); test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, 5); test(S("lmofqdhpki"), SV(""), 9, S::npos); test(S("hnefkqimca"), SV("rtjpa"), 9, 9); test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, S::npos); test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, 9); test(S("elgofjmbrq"), SV(""), 10, S::npos); test(S("mjqdgalkpc"), SV("dplqa"), 10, S::npos); test(S("kthqnfcerm"), SV("dkacjoptns"), 10, S::npos); test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos); test(S("eqsgalomhb"), SV(""), 11, S::npos); test(S("akiteljmoh"), SV("lofbc"), 11, S::npos); test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, S::npos); test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos); test(S("snafbdlghrjkpqtoceim"), SV(""), 0, S::npos); test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 3); test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, 0); test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, 0); test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, S::npos); test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 3); test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 1); test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, 1); test(S("hdpkobnsalmcfijregtq"), SV(""), 10, S::npos); test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 10); test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 10); test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, 10); test(S("niptglfbosehkamrdqcj"), SV(""), 19, S::npos); test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, S::npos); test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 19); test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, 19); test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, S::npos); test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, S::npos); test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, S::npos); test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos); test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, S::npos); test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, S::npos); test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, S::npos); test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos); }