📄 voutfloatn.br
字号:
float2 nextPlaceToLook; getIndexAt(indexof(output),-sign*halfk,maxvalue,nextPlaceToLook); valueAtfloat(scatterindex,nextPlaceToLook,neighbor,maxvalue,0); if (neighbor>halfk) { output=halfk+twotologkminusi; }else { float2 actualValue; valueAtfloat2(value,nextPlaceToLook,actualValue,maxvalue,0); if (neighbor==halfk&&!isinf(actualValue.x)) { output=halfk; }else { output = halfk-twotologkminusi; } }}kernel void EstablishGuessfloat2(float scatterindex[][], out float output<>, float2 value[][], float twotologkminusi, float2 maxvalue, float halfk, float sign) { if (scatterindex[indexof(output)]==0) { output=0; } else { GatherGuessfloat2(scatterindex, output, value, twotologkminusi, maxvalue, halfk, sign); }}kernel void UpdateGuessfloat2(float scatterindex[][], out float output<>, float2 value[][], float twotologkminusi, float2 maxvalue, float lastguess<>, float sign) { GatherGuessfloat2(scatterindex, output, value, twotologkminusi, maxvalue, lastguess, sign);}kernel void RelativeGatherfloat2(out float2 output<>, float gatherindex[][], float2 value[][], float inf<>, float sign, float2 maxvalue, float maxshift) { float2 nextPlaceToLook; float2 isoffedge; getIndexAt(indexof(output), -sign.x*gatherindex[indexof(output)], maxvalue, nextPlaceToLook); getIndexAt(indexof(output),-sign.x*maxshift,maxvalue,isoffedge); isoffedge-=maxvalue; if (isoffedge.y>=-.0625 || (isoffedge.y>=-1.0625&&isoffedge.x>=-.0625)) { output=inf; }else { output=value[nextPlaceToLook]; }}float shiftValuesfloat2(float2 list_stream <>, float2 (*output_stream)<>, int WIDTH, int LENGTH, int sign) { float tmp_stream<WIDTH,LENGTH>; float ret_stream<WIDTH,LENGTH>; float guess_stream<WIDTH,LENGTH>; unsigned int i; float2 maxvalue; unsigned int logN; unsigned int LogNMinusK; float maxshift; maxvalue.x=(float)LENGTH;maxvalue.y=(float)WIDTH; logN=(unsigned int)ceil(log((float)LENGTH*WIDTH)/log(2.0f)); debugStreamPrint(list_stream,"Combined..."); NanToBoolRightfloat2 (list_stream,ret_stream,(float)sign,maxvalue); for (i=1;i<logN;++i) { streamSwap(ret_stream,tmp_stream); NanToRightfloat2(tmp_stream,ret_stream,(float)sign*(1<<i),maxvalue); } debugStreamPrint(ret_stream,"scattering..."); { float item<1>; float2 index; if (sign==-1) { index.y = (float)(WIDTH-1); index.x = (float)(LENGTH-1); }else { index.y=index.x=0; } kernelReadItem(ret_stream,index,item); streamWrite(item,&maxshift); } LogNMinusK=logN-2; i= logN-1;//could make this k! rather than N // where k = num elements pushed (N-logN%2?ret_stream,tmp_stream EstablishGuessfloat2(ret_stream, guess_stream, list_stream, (float)(1 << LogNMinusK), maxvalue, (float)(1<<i), (float)sign); for (i=1;i<logN;++i) { LogNMinusK=logN-1-i; streamSwap(tmp_stream,guess_stream); UpdateGuessfloat2 (ret_stream,//scatter values guess_stream,//new guess list_stream,//actual values (float)(1<<LogNMinusK), maxvalue, tmp_stream,//old guess (float)sign); } debugStreamPrint(guess_stream,"Gather Value"); if (1) { unsigned int size,width; size = (unsigned int)LENGTH*(unsigned int)WIDTH - (unsigned int) maxshift; width = size/LENGTH+((size%LENGTH)?1:0); if (1) { float2 proper_output_stream<width,LENGTH>; if (width) { RelativeGatherfloat2(proper_output_stream, guess_stream, list_stream, *sentinelStream(2), (float)sign, maxvalue, maxshift); } streamSwap(*output_stream,proper_output_stream); } debugStreamPrint(*output_stream, "Final Value"); } return maxshift;}kernel void float2streamCombine1(float2 input0[][], float modulus, float offset, float length, float lengthmodmodulus, float2 oldoutput<>, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, offset, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else { output=oldoutput; }}kernel void float2streamCombine2f(float2 input0[][], float2 input1[][], float modulus, float length, float lengthmodmodulus, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, -0.5f, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else { output=input1[newindex]; }}kernel void float2streamCombine2(float2 input0[][], float2 input1[][], float modulus, float offset, float length, float lengthmodmodulus, float2 oldoutput<>, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, offset, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else { output=oldoutput; }}kernel void float2streamCombine3f(float2 input0[][], float2 input1[][], float2 input2[][], float modulus, float length, float lengthmodmodulus, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, -0.5f, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else { output=input2[newindex]; }}kernel void float2streamCombine3(float2 input0[][], float2 input1[][], float2 input2[][], float modulus, float offset, float length, float lengthmodmodulus, float2 oldoutput<>, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, offset, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else if (whichmod==2) { output=input2[newindex]; }else { output=oldoutput; }}kernel void float2streamCombine4f(float2 input0[][], float2 input1[][], float2 input2[][], float2 input3[][], float modulus, float length, float lengthmodmodulus, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, -0.5f, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else if (whichmod==2) { output=input2[newindex]; }else { output=input3[newindex]; }}kernel void float2streamCombine4(float2 input0[][], float2 input1[][], float2 input2[][], float2 input3[][], float modulus, float offset, float length, float lengthmodmodulus, float2 oldoutput<>, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, offset, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else if (whichmod==2) { output=input2[newindex]; }else if (whichmod==3) { output=input3[newindex]; }else { output=oldoutput; }}kernel void float2streamCombine5f(float2 input0[][], float2 input1[][], float2 input2[][], float2 input3[][], float2 input4[][], float modulus, float length, float lengthmodmodulus, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, -0.5f, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex]; }else if (whichmod==2) { output=input2[newindex]; }else if (whichmod==3) { output=input3[newindex]; }else { output=input4[newindex]; }}/*kernel void float2streamCombine5(float2 input0[][], float2 input1[][], float2 input2[][], float2 input3[][], float2 input4[][], float modulus, float offset, float length, float lengthmodmodulus, float2 oldoutput<>, out float2 output <>) { float2 newindex; float whichmod; calculateDividedIndex(indexof(output), modulus, length, newindex); calculateIndexModulus(indexof(output), modulus, offset, lengthmodmodulus, whichmod); if (whichmod==0||whichmod==modulus) { output=input0[newindex]; }else if (whichmod==1) { output=input1[newindex];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -