Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <omp.h>
- #include <malloc.h>
- #include <stdio.h>
- #include <xmmintrin.h>
- #define N 1000
- int main() {
- double* vector1 = malloc(sizeof(double) * N);
- double* vector2 = malloc(sizeof(double) * N);
- for (unsigned int i = 0; i < N; i++) {
- vector1[i] = i;
- vector2[i] = 1 / (double) i;
- }
- #pragma omp parallel
- {
- const int thread_num = omp_get_thread_num();
- const int num_threads = omp_get_num_threads();
- const int k1 = thread_num * N / num_threads;
- const int k2 = (thread_num + 1) * N / num_threads;
- __m128d* x = (__m128d*) (vector1 + k1);
- __m128d* y = (__m128d*) (vector2 + k1);
- __m128d tmp1 = x[0];
- __m128d tmp2 = y[0];
- }
- free(vector1);
- free(vector2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement