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
150116_FactorialPrimo
assignment 3 celina
A_141121_mayorMenor
fork() System call
WAP in C to delete an element from an array
Spring 2017 Project 2 v1
1
more_than_one_break_in_loop
18BCE2182 ASSESS_1 Q2-2
A_141205_Palindromo