Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <omp.h>
- int N;
- float * dataX;
- float * dataY;
- void printVector (const float *p, const int N) {
- for (int i=0; i<N; i++)
- printf("%f\n",p[i]);
- }
- int main(int argc, char *argv[])
- {
- if(argc <= 1)
- printf("ERROR");
- else
- {
- N = atoi(argv[1]);
- dataX = (float*)malloc(N*sizeof(float));
- dataY = (float*)malloc(N*sizeof(float));
- // and fill with some arbitrary values
- for(int j=0;j<N;j++)
- {
- #pragma omp parallel for
- for (int i=0; i<N; i++)
- {
- dataX[i] = 10;
- dataY[i] = 20;
- }
- #pragma omp parallel for
- for (int i=0; i<N; i++)
- {
- dataY[i] = dataY[i] * dataX[i];
- }
- }
- //printVector (dataY,N);
- free(dataX);
- free(dataY);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement