21 for(i=0; i<count-1 ; i++){
24 while(j != -1 && tmp < indices[j]){
25 indices[j+1] = indices[j];
49 while((i<=right) && (indices[i]<=key)) i++;
50 while ((j>left) && (indices[j]>key)) j--;
53 indices[i] = indices[j];
60 indices[left] = indices[j];
75 for (i=(count-1); i>0; i--){
76 for (j = 1; j <= i; j++){
77 if (indices[j-1] > indices[j]){
79 indices[j-1] = indices[j];
101 for(i=1; i<count ; i++){
110 buf = (
int *) calloc(max-min+1,
sizeof(
int));
111 for(i=0; i<count ; i++){
112 buf[indices[i]-min]=1;
115 for(i=0; i<(max-min+1) ; i++){
131 for(m = n/2;m>0;m/=2){
133 for(i=j-m;i>=0;i-=m){
161 int ssort(
int *indices,
int count,
int flag){
184 for(i=0; i<count-1; i++){
186 if(*ptr_i != *ptr_o){
207 #pragma omp parallel shared(nths)
209 nths = omp_get_num_threads();
217 count = (
int *) malloc(nths *
sizeof(
int));
218 disp = (
int *) malloc(nths *
sizeof(
int));
220 for(i=0; i<nths; i++){
229 for(i=0; i<nths-1; i++){
230 disp[i+1] = disp[i] + count[i];
233 #pragma omp parallel private(tid, n, k, d, buf) shared(nths, A, nA, disp, count)
235 tid = omp_get_thread_num();
237 buf = (
int *) malloc(nA*
sizeof(
int));
239 memcpy(buf, A+disp[tid], count[tid]*
sizeof(
int));
241 n =
ssort(buf, count[tid], flag);
244 memcpy(A+disp[tid], buf, n*
sizeof(
int));
246 nths = omp_get_num_threads();
253 if(tid%(2*d)==0 && tid+d<nths){
254 set_or(A+disp[tid], count[tid] , A+disp[tid+d], count[tid+d], buf);
256 memcpy(A+disp[tid], buf, n*
sizeof(
int));
300 #pragma omp parallel private(tid) shared(nths)
302 nths = omp_get_num_threads();
308 count = (
int *) malloc(nths *
sizeof(
int));
309 disp = (
int *) malloc(nths *
sizeof(
int));
311 for(i=0; i<nths; i++){
321 for(i=0; i<nths-1; i++){
322 disp[i+1] = disp[i] + count[i];
325 #pragma omp parallel private(tid, n) shared(A, disp, count)
327 tid = omp_get_thread_num();
328 n =
ssort(A+disp[tid], count[tid], flag);
332 buf = (
int *) malloc(nA*
sizeof(
int));
334 #pragma omp parallel private(tid, n, k, d) shared(nths, nA, A, disp, count, buf)
336 tid = omp_get_thread_num();
337 nths = omp_get_num_threads();
341 if(tid%(2*d)==0 && tid+d<nths){
343 n =
card_or(A+disp[tid], count[tid] , A+disp[tid+d], count[tid+d]);
344 set_or(A+disp[tid], count[tid] , A+disp[tid+d], count[tid+d], buf+disp[tid]);
346 memcpy(A+disp[tid], buf+disp[tid], n*
sizeof(
int));
367 if(indices[i]>indices[i+1]){
380 if(indices[i]>=indices[i+1]){