Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Loop-worksharing
#include <omp.h> #include <stdio.h> #include <stdlib.h> #define CHUNKSIZE 10 #define N 100 int main () { int nthreads, tid, i, chunk; float a[N], b[N], c[N]; for (i=0; i< N; i++) a[i] = b[i] = i* 1.0; chunk = CHUNKSIZE; #pragma omp parallel shared(a,b,c,nthreads,chunk) private(i,tid) { tid= omp_get_thread_num(); if (tid== 0) { nthreads= omp_get_num_threads(); printf("Number of threads = %d\n", nthreads); } printf("Thread %d starting...\n",tid); #pragma ompfor schedule(dynamic, chunk) for (i=0; i<N; i++) { c[i] = a[i] + b[i]; printf("Thread %d: c[%d]= %f\n",tid,i,c[i]); } } /* end of parallel section */ }
run
|
edit
|
history
|
help
0
B_141202_CADENA_NUMERO
arrows
Project 4 v0.1
CO_assign_q1
project menu
Why &(a+1) is not allowed
Atomic Openmp
18BCE2182 ASSESS_1 Q1-7
segundo avance de la lista enlazada
thread SleepWakeup and mutex