📄 opt_costmodel.c
字号:
#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 197 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" } else if (getFunctionId(p) == appendRef || getFunctionId(p) == insertRef ){#line 213 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" if( isaBatType(getArgType(mb,p,2)) ){ /* insert BAT */ #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,2)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1 + *c2+1); fixPropertySet(mb, getArg(p,1)); setProperty(getProps(mb,getArg(p,1)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 2 into 1: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 215 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" OPTbackpropagate(mb,i,getArg(p,1)); } else { /* insert scalars */ #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1 +1); fixPropertySet(mb, getArg(p,1)); setProperty(getProps(mb,getArg(p,1)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 1: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 219 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" OPTbackpropagate(mb,i,getArg(p,1)); } } else if (getFunctionId(p) == deleteRef){ if( isaBatType(getArgType(mb,p,2)) ){ /* delete BAT */ #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,2)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( (*c1 - *c2 ==0? 1: *c1-*c2)); fixPropertySet(mb, getArg(p,1)); setProperty(getProps(mb,getArg(p,1)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 2 into 1: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 225 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" OPTbackpropagate(mb,i,getArg(p,1)); } else { /* insert scalars */ #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1==1?1: *c1-1); fixPropertySet(mb, getArg(p,1)); setProperty(getProps(mb,getArg(p,1)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 1: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 229 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" OPTbackpropagate(mb,i,getArg(p,1)); } OPTbackpropagate(mb,i,getArg(p,1)); } else if ( getFunctionId(p) == insertRef){ #line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1 + 1); fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 234 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" /* faked */ OPTbackpropagate(mb,i,getArg(p,1)); } } else if (getModuleId(p)==groupRef) { if (getFunctionId(p) ==newRef) { #line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1 / 10+1); fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 239 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" } else { #line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1); fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 241 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" } } else if (getModuleId(p)== aggrRef) { if (getFunctionId(p) == sumRef || getFunctionId(p) == minRef || getFunctionId(p) == maxRef || getFunctionId(p) == avgRef) { #line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( *c1?*c1:*c1+1); fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 248 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" } else if (getFunctionId(p) == countRef){ #line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" #line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{ c1 = getVarRows(getArg(p,1)); c2 = getVarRows(getArg(p,1)); if( c1 == NULL) continue; if( c2 == NULL) continue; k= ( 1); fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k); printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 250 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx" } } else if( p->token == ASSIGNsymbol && p->argc== 2){ /* copy the rows property */ c1 = getVarRows(getArg(p,1)); if( c1 != NULL){ fixPropertySet(mb, getArg(p,0)); setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int,c1); } } } return 1;}#line 270 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 265 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"/* #define _DEBUG_OPTIMIZER_*/str OPTcostModel(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){ str modnme; str fcnnme; Module scope=NULL; Symbol s= NULL; lng clk= GDKusec(); int actions = 0; optimizerInit(); if( p ) removeInstruction(mb, p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"apply costModel\n"); printFunction(GDKout,mb,LIST_MAL_ALL);#endif if( p && p->argc > 1 && getFunctionId(p) != multiplexRef){#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"locate function costModel\n");#endif if( getArgType(mb,p,1) != TYPE_str || getArgType(mb,p,2) != TYPE_str || !isConstant(mb,getArg(p,1)) || !isConstant(mb,getArg(p,2)) ) { char buf[1024]; snprintf(buf,1024, "Optimizer requires constant string arguments\n"); throw(MAL, "optimizer.costModel",buf); } if( stk != 0){ modnme= (str)getArgValue(stk,p,1); fcnnme= (str)getArgValue(stk,p,2); } else { modnme= getArgDefault(mb,p,1); fcnnme= getArgDefault(mb,p,2); } scope = findModule(MCgetClient()->nspace,putName(modnme,strlen(modnme)) ); if( scope) s= findSymbolInModule(scope,putName(fcnnme,strlen(fcnnme))); if( s == NULL) { char buf[1024]; snprintf(buf,1024, "Could not find %s.%s\n",modnme,fcnnme); throw(MAL, "optimizer.costModel",buf); }#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"costModel %s %d\n",modnme,fcnnme);#endif mb = s->def; stk= 0; } if( mb->errors ) return MAL_SUCCEED; addtoMalBlkHistory(mb); actions= OPTcostModelImplementation(mb,stk,p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"finished costModel %d\n",actions); printFunction(GDKout,mb,LIST_MAL_ALL);#endif optimizerCheck(mb, "optimizer.costModel", actions, GDKusec() - clk,0); return MAL_SUCCEED;}#line 270 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 272 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -