create-pl1-omp 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -1
- package/package.json +1 -1
- package/template/PL3/PL3.c +34 -0
package/index.js
CHANGED
|
@@ -12,7 +12,8 @@ async function run() {
|
|
|
12
12
|
choices: [
|
|
13
13
|
{ title: 'All Programs', value: 'ALL' },
|
|
14
14
|
{ title: 'PL1 - Parallel Merge Sort (OpenMP)', value: 'PL1' },
|
|
15
|
-
{ title: 'PL2 - OpenMP Static Loop Scheduling', value: 'PL2' }
|
|
15
|
+
{ title: 'PL2 - OpenMP Static Loop Scheduling', value: 'PL2' },
|
|
16
|
+
{ title: 'PL3 - Fibonacci Series using OpenMP Tasks', value: 'PL3' }
|
|
16
17
|
],
|
|
17
18
|
initial: 0,
|
|
18
19
|
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <omp.h>
|
|
3
|
+
|
|
4
|
+
int fib(int n) {
|
|
5
|
+
int i, j;
|
|
6
|
+
if (n < 2)
|
|
7
|
+
return n;
|
|
8
|
+
else {
|
|
9
|
+
#pragma omp task shared(i) firstprivate(n)
|
|
10
|
+
i = fib(n - 1);
|
|
11
|
+
|
|
12
|
+
#pragma omp task shared(j) firstprivate(n)
|
|
13
|
+
j = fib(n - 2);
|
|
14
|
+
|
|
15
|
+
#pragma omp taskwait
|
|
16
|
+
return i + j;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
int main() {
|
|
21
|
+
int n;
|
|
22
|
+
printf("Enter the Fibonacci number to calculate: ");
|
|
23
|
+
scanf("%d", &n);
|
|
24
|
+
|
|
25
|
+
omp_set_dynamic(0);
|
|
26
|
+
omp_set_num_threads(4);
|
|
27
|
+
|
|
28
|
+
#pragma omp parallel shared(n)
|
|
29
|
+
{
|
|
30
|
+
#pragma omp single
|
|
31
|
+
printf ("fib(%d) = %d\n", n, fib(n));
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|