create-pl1-omp 1.0.1 → 1.0.3
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 +12 -14
- package/package.json +1 -1
- package/template/PL2/PL2.c +16 -0
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs-extra');
|
|
@@ -10,32 +10,30 @@ async function run() {
|
|
|
10
10
|
name: 'program',
|
|
11
11
|
message: 'Select the lab program to generate:',
|
|
12
12
|
choices: [
|
|
13
|
-
{ title: '
|
|
14
|
-
|
|
13
|
+
{ title: 'All Programs', value: 'ALL' },
|
|
14
|
+
{ title: 'PL1 - Parallel Merge Sort (OpenMP)', value: 'PL1' },
|
|
15
|
+
{ title: 'PL2 - OpenMP Static Loop Scheduling', value: 'PL2' }
|
|
15
16
|
],
|
|
16
17
|
initial: 0,
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
if (!response.program) {
|
|
20
|
-
console.log('Action cancelled.');
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const targetDir = process.cwd();
|
|
25
25
|
const templateBase = path.join(__dirname, 'template');
|
|
26
26
|
|
|
27
|
-
const srcFolder = path.join(templateBase, response.program);
|
|
28
|
-
const destFolder = path.join(targetDir, response.program);
|
|
29
|
-
|
|
30
27
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
if (response.program === 'ALL') {
|
|
29
|
+
await fs.copy(templateBase, targetDir, { overwrite: true });
|
|
30
|
+
} else {
|
|
31
|
+
const srcFolder = path.join(templateBase, response.program);
|
|
32
|
+
const destFolder = path.join(targetDir, response.program);
|
|
33
|
+
await fs.copy(srcFolder, destFolder, { overwrite: true });
|
|
34
|
+
}
|
|
35
|
+
console.log('done');
|
|
37
36
|
} catch (err) {
|
|
38
|
-
console.error('❌ Failed to copy template folder:', err);
|
|
39
37
|
process.exit(1);
|
|
40
38
|
}
|
|
41
39
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <omp.h>
|
|
3
|
+
|
|
4
|
+
int main() {
|
|
5
|
+
int num_iterations;
|
|
6
|
+
printf("Enter the number of iterations: ");
|
|
7
|
+
scanf("%d", &num_iterations);
|
|
8
|
+
#pragma omp parallel
|
|
9
|
+
{
|
|
10
|
+
#pragma omp for schedule(static,2)
|
|
11
|
+
for (int i = 0; i < num_iterations; i++) {
|
|
12
|
+
printf("Thread %d: Iteration %d\n", omp_get_thread_num(), i);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|