Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GNU nano 2.2.6 Plik: sekcje.c
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <omp.h>
- #ifndef _OPENMP
- #define omp_get_num_threads() 1
- #define omp_get_thread_num() 0
- #define omp_get_wtime() 0
- #endif
- int main()
- {
- double czas_wtime1, czas_wtime2;
- czas_wtime1 = omp_get_wtime();
- #pragma omp parallel
- {
- printf("Ilosc wszystkich watkow wynosi %d\n", omp_get_num_threads());
- #pragma omp sections
- {
- #pragma omp section
- {
- printf("Numer watku wykonujacy sekcje 1 to %d\n", omp_get_thread_num());
- sleep(1);
- }
- #pragma omp section
- {
- printf("Numer watku wykonujacy sekcje 2 to %d\n", omp_get_thread_num());
- sleep(1);
- }
- #pragma omp section
- {
- printf("Numer watku wykonujacy sekcje 3 to %d\n", omp_get_thread_num());
- sleep(1);
- }
- }
- }
- czas_wtime2 = omp_get_wtime();
- printf("Czas wykonania wtime wynosi %lf s\n", (czas_wtime2 - czas_wtime1));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement