Advertisement
Guest User

Untitled

a guest
Oct 5th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char** argv) {
  5.  
  6. /*********************** FPGA *************************/
  7. int workers, gangs, sizeF;
  8.  
  9. workers = 16;
  10. gangs = 256;
  11. sizeF = workers * gangs;
  12.  
  13. float *D, *E;
  14. int j;
  15. int sum = 0;
  16. D = (float*) malloc(sizeF * sizeof(float));
  17. E = (float*) malloc(sizeF * sizeof(float));
  18.  
  19. for (j = 0; j < sizeF; j++) {
  20. D[j] = (float) j;
  21. }
  22.  
  23. // #pragma acc data copyin(D[0:sizeF]) copyout(sum)
  24. #pragma acc data copyin(D[0:sizeF]) copyout(E[0:sizeF])
  25. {
  26. #pragma acc kernels
  27. {
  28. #pragma acc loop independent
  29. for (j = 0; j < sizeF; j++) {
  30. E[j] = D[j];
  31. }
  32. }
  33. }
  34.  
  35. // for (j = 0; j < sizeF; j++) {
  36. // sum += E[j];
  37. // }
  38.  
  39. for (j = 0; j < sizeF; j++) {
  40. if (D[j] != E[j]) sum++;
  41. }
  42. printf("errorFPGA:%d\n", sum);
  43.  
  44. // printf("sum:%f\n", sum);
  45. //printf("sum:%f\n", sum);
  46. /********************************************************/
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement