正在加载图片...
F-index[2*) error(charch) MPL_CHAR,( printf("%sn", ch), MULTI TYP E+MyID MPI COMM wRD|严串行快速排序算法 quicksort(int *datas, int bb, int ee) I=templ[; MPI Recv(&ariK MPI CHAR 1. MULTI TYPE+I MPI COMM WORLD &status [j++D while((isj)&&(tt<=datas) kk+l if(isj) MPI Barrier( MPI COMM WORLD) datas[=datas[; hile((isn)&& MPI Barrier(MPI COMM WORLD) (ttdatasD)) 每个处理器再通过P路归并排序将上 if (isj) 步的到的数据排序:从而这n个 数据便是有序的,对应于算法13.5 datas= datas 骤(7) f(=j) multimerge(arrl, templ, arr, &k, SumID); datas[]=tt, MPI Barrier(MPI COMM WORLD); else datas[]=tt; printf("On node %d the sorted data is for(F0; i<mylength, 1++) datas[=tt, printf("%d: " arr), quicksort(datas, i+l, ee) 输出错误信息*9 ]-index[2*n]) ,MPI_CHAR, n, MULTI_TYP E+MyID, MPI_COMM _WORLD); } } else { l = temp1[i]; MPI_Recv(&arr1[k], l*sizeof(int), MPI_CHAR, i ,MULTI_TYPE+i, MPI_COMM_WORLD, &status[j++]); k=k+l; } MPI_Barrier( MPI_COMM_WORLD); } mylength = k; MPI_Barrier(MPI_COMM_WORLD); /*每个处理器再通过 P 路归并排序将上 一步的到的数据排序;从而这 n 个 数据便是有序的,,对应于算法 13.5 步骤(7) */ k = 0; multimerge(arr1,temp1,arr,&k,SumID); MPI_Barrier(MPI_COMM_WORLD); } printf("On node %d the sorted data is : \n",MyID); for (i=0;i<mylength;i++) printf("%d : ",arr[i]); printf("\n"); } /*输出错误信息*/ merror(char* ch) { printf("%s\n",ch); exit(1); } /*串行快速排序算法*/ quicksort(int *datas,int bb,int ee) { int tt,i,j; t = datas[bb]; = bb; j = ee; if (i<j) { while(i<j) { while ((i<j)&&(tt<=datas[j])) j--; if (i<j) { datas[i] = datas[j]; i++; while ((i<j)&& (tt>datas[i])) i++; if (i<j) { datas[j] = datas[i]; j--; if (i==j) datas[i] = tt; } else datas[j] = tt; } else datas[i] = tt; } quicksort(datas,bb,i-1); quicksort(datas,i+1,ee); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有