daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest May 16th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include "stdlib.h"
  3. #include "string.h"
  4. #include "sys/time.h"
  5.  
  6. #define SIZE    (128*2048)
  7. unsigned long long A[SIZE];
  8. unsigned long long B[SIZE];
  9. unsigned long long C[SIZE];
  10. unsigned long long D[SIZE];
  11.  
  12.  
  13. #pragma omp target device(fpga)  implements(simple_code)  copy_in(a,b,c)  copy_out(d)
  14. extern void sw_compute(unsigned long long a[SIZE], unsigned long long b[SIZE], unsigned long long c[SIZE], unsigned long long d[SIZE])
  15.  
  16. int main(int argc, char **argv)
  17. {
  18.     unsigned char   *p1, *p2, *p3, *p4;
  19.     int             i;
  20.  
  21.     p1 = (char *)A;
  22.     p2 = (char *)B;
  23.     p3 = (char *)C;
  24.     p4 = (char *)D;
  25.     for (i = 0; i < SIZE * sizeof(unsigned long long); i++) {
  26.         *p1++ = i;
  27.         *p2++ = i-1;
  28.         *p3++ = i-2;
  29.         *p4++ = i-3;
  30.     }
  31.  
  32. #pragma omp task label(simple_code) input(A[0:SIZE-1],B[0:SIZE-1],C[0:SIZE-1]) output(D[0:SIZE-1])
  33.     for (i=0;i<SIZE;i++) {
  34.         D[i] = A[i] & B[i] | C[i];
  35.     }
  36.  
  37. /* Alternativa:
  38.    Este codigo generaria el anterior en un paso intermedio, por lo que
  39.    es lo mismo.
  40.     for (i=0;i<SIZE;i++) {
  41. #pragma omp block nest(1) factor(SIZE)
  42. #pragma omp task label(simple_code) input(A[i],B[i],C[i])  output(D[i])
  43.         D[i] = A[i] & B[i] | C[i];
  44.     }
  45.  
  46.  
  47. */
  48.  
  49.     return 0;
  50. }
RAW Paste Data
Top