Created
November 26, 2009 13:44
-
-
Save jrom/243466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "stdlib.h" | |
#include "string.h" | |
#include "sys/time.h" | |
#define SIZE (128*2048) | |
unsigned long long A[SIZE]; | |
unsigned long long B[SIZE]; | |
unsigned long long C[SIZE]; | |
unsigned long long D[SIZE]; | |
#pragma omp target device(fpga) implements(simple_code) copy_in(a,b,c) copy_out(d) | |
extern void sw_compute(unsigned long long a[SIZE], unsigned long long b[SIZE], unsigned long long c[SIZE], unsigned long long d[SIZE]) | |
int main(int argc, char **argv) | |
{ | |
unsigned char *p1, *p2, *p3, *p4; | |
int i; | |
p1 = (char *)A; | |
p2 = (char *)B; | |
p3 = (char *)C; | |
p4 = (char *)D; | |
for (i = 0; i < SIZE * sizeof(unsigned long long); i++) { | |
*p1++ = i; | |
*p2++ = i-1; | |
*p3++ = i-2; | |
*p4++ = i-3; | |
} | |
#pragma omp task label(simple_code) input(A[0:SIZE-1],B[0:SIZE-1],C[0:SIZE-1]) output(D[0:SIZE-1]) | |
for (i=0;i<SIZE;i++) { | |
D[i] = A[i] & B[i] | C[i]; | |
} | |
/* Alternativa: | |
Este codigo generaria el anterior en un paso intermedio, por lo que | |
es lo mismo. | |
for (i=0;i<SIZE;i++) { | |
#pragma omp block nest(1) factor(SIZE) | |
#pragma omp task label(simple_code) input(A[i],B[i],C[i]) output(D[i]) | |
D[i] = A[i] & B[i] | C[i]; | |
} | |
*/ | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment