AnsweredAssumed Answered

opencl- filtering of a vektor

Question asked by christa_bln on Aug 5, 2019

Does the following small program faster on GPU ?

The vektor a[] should have 1000 member.

 

/* select values */
#include <stdio.h>

 

int main()
{int a[15]={7,8,0,4,13,1,19,5,10,2,3,19,12,6,9};
 int i, num_filtered;
 printf("input datas:           ");
 for (i=0;i<15;i++) printf("3d",a[i]);
 printf("\n");
 num_filtered=0;
 for (i=0;i<15;i++) if (a[i]!=19) {a[num_filtered]=a[i];num_filtered +=1;}
 printf("output filtered datas: ");
 for (i=0;i<num_filtered;i++) printf("3d",a[i]);
 printf("\n");
}

// input datas:                7  8  0  4 13  1 19  5 10  2  3 19 12  6  9
// output filtered datas:  7  8  0  4 13  1  5 10  2  3 12  6  9

Outcomes