Skip to content

Commit 42415e6

Browse files
explicitly load libomp.so when required
remove the need to set env var PATH & LD_LIBRARY_PATH for omp kernels
1 parent 903e597 commit 42415e6

File tree

13 files changed

+135
-149
lines changed

13 files changed

+135
-149
lines changed

notebooks/openmp-notebooks/hello_world.ipynb

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,12 @@
88
"outputs": [],
99
"source": [
1010
"#include <stdio.h>\n",
11-
"#include <omp.h>\n",
12-
"#include <clang/Interpreter/CppInterOp.h>"
11+
"#include <omp.h>"
1312
]
1413
},
1514
{
1615
"cell_type": "code",
1716
"execution_count": 2,
18-
"id": "ef1cd58a-672c-4a6f-843a-6c88fc4911f3",
19-
"metadata": {},
20-
"outputs": [],
21-
"source": [
22-
"Cpp::LoadLibrary(\"libomp\");\n",
23-
" "
24-
]
25-
},
26-
{
27-
"cell_type": "code",
28-
"execution_count": 3,
2917
"id": "c2b754ad-9553-4a42-b990-f990a9a269ed",
3018
"metadata": {},
3119
"outputs": [],
@@ -48,24 +36,32 @@
4836
},
4937
{
5038
"cell_type": "code",
51-
"execution_count": 4,
39+
"execution_count": 3,
5240
"id": "a37a13d4-fc82-496e-8f42-9e718a8c2aa0",
5341
"metadata": {},
5442
"outputs": [
5543
{
5644
"name": "stdout",
5745
"output_type": "stream",
5846
"text": [
59-
"max threads: 8\n",
60-
"Hello World from thread = 0 with 8 threads\n",
61-
"Hello World from thread = 3 with 8 threads\n",
62-
"Hello World from thread = 4 with 8 threads\n",
63-
"Hello World from thread = 2 with 8 threads\n",
64-
"Hello World from thread = 7 with 8 threads\n",
65-
"Hello World from thread = 1 with 8 threads\n",
66-
"Hello World from thread = 6 with 8 threads\n",
67-
"Hello World from thread = 5 with 8 threads\n",
68-
"all done, with hopefully 8 threads\n"
47+
"max threads: 16\n",
48+
"Hello World from thread = 0 with 16 threads\n",
49+
"Hello World from thread = 3 with 16 threads\n",
50+
"Hello World from thread = 13 with 16 threads\n",
51+
"Hello World from thread = 4 with 16 threads\n",
52+
"Hello World from thread = 12 with 16 threads\n",
53+
"Hello World from thread = 1 with 16 threads\n",
54+
"Hello World from thread = 14 with 16 threads\n",
55+
"Hello World from thread = 15 with 16 threads\n",
56+
"Hello World from thread = 8 with 16 threads\n",
57+
"Hello World from thread = 6 with 16 threads\n",
58+
"Hello World from thread = 11 with 16 threads\n",
59+
"Hello World from thread = 5 with 16 threads\n",
60+
"Hello World from thread = 7 with 16 threads\n",
61+
"Hello World from thread = 10 with 16 threads\n",
62+
"Hello World from thread = 9 with 16 threads\n",
63+
"Hello World from thread = 2 with 16 threads\n",
64+
"all done, with hopefully 16 threads\n"
6965
]
7066
}
7167
],
@@ -76,7 +72,7 @@
7672
],
7773
"metadata": {
7874
"kernelspec": {
79-
"display_name": "C++17 (xcpp+OpenMP)",
75+
"display_name": "C++17 + OpenMP",
8076
"language": "cpp",
8177
"name": "xcpp17-omp"
8278
},

notebooks/openmp-notebooks/linked_list.ipynb

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"source": [
1010
"#include <stdlib.h>\n",
1111
"#include <stdio.h>\n",
12-
"#include <omp.h>\n",
13-
"#include <clang/Interpreter/CppInterOp.h>"
12+
"#include <omp.h>"
1413
]
1514
},
1615
{
@@ -31,16 +30,6 @@
3130
{
3231
"cell_type": "code",
3332
"execution_count": 3,
34-
"id": "8da842e1-db02-49e0-929d-4e67cbc08172",
35-
"metadata": {},
36-
"outputs": [],
37-
"source": [
38-
"Cpp::LoadLibrary(\"libomp\");"
39-
]
40-
},
41-
{
42-
"cell_type": "code",
43-
"execution_count": 4,
4433
"id": "22f97c49-78d1-496e-ac7c-978aed95331a",
4534
"metadata": {},
4635
"outputs": [],
@@ -54,7 +43,7 @@
5443
},
5544
{
5645
"cell_type": "code",
57-
"execution_count": 5,
46+
"execution_count": 4,
5847
"id": "b16b1e8a-8831-4b8d-9d57-09deeaaa88ee",
5948
"metadata": {},
6049
"outputs": [],
@@ -66,7 +55,7 @@
6655
},
6756
{
6857
"cell_type": "code",
69-
"execution_count": 6,
58+
"execution_count": 5,
7059
"id": "0ef8af6c-1d6f-4c68-84bc-3dd1d8092b06",
7160
"metadata": {},
7261
"outputs": [],
@@ -85,7 +74,7 @@
8574
},
8675
{
8776
"cell_type": "code",
88-
"execution_count": 7,
77+
"execution_count": 6,
8978
"id": "1fa0307d-fdc9-4503-95cb-1c6448791354",
9079
"metadata": {},
9180
"outputs": [],
@@ -101,7 +90,7 @@
10190
},
10291
{
10392
"cell_type": "code",
104-
"execution_count": 8,
93+
"execution_count": 7,
10594
"id": "03acb599-9329-49ff-8aff-c0902adb6c3c",
10695
"metadata": {},
10796
"outputs": [],
@@ -130,7 +119,7 @@
130119
},
131120
{
132121
"cell_type": "code",
133-
"execution_count": 9,
122+
"execution_count": 8,
134123
"id": "f2dfb41b-e55f-43c0-b7f6-546a1697acb1",
135124
"metadata": {},
136125
"outputs": [],
@@ -188,7 +177,7 @@
188177
},
189178
{
190179
"cell_type": "code",
191-
"execution_count": 10,
180+
"execution_count": 9,
192181
"id": "353e5dfd-fcae-43e6-97e3-ec98070811a1",
193182
"metadata": {},
194183
"outputs": [
@@ -199,14 +188,14 @@
199188
"Process linked list\n",
200189
" Each linked list node will be processed by function 'processwork()'\n",
201190
" Each ll node will compute 5 fibonacci numbers beginning with 38\n",
202-
"Threads: 8\n",
191+
"Threads: 16\n",
203192
"38 : 39088169\n",
204193
"39 : 63245986\n",
205194
"40 : 102334155\n",
206195
"41 : 165580141\n",
207196
"42 : 267914296\n",
208197
"43 : 433494437\n",
209-
"Compute Time: 2.617225 seconds\n"
198+
"Compute Time: 3.560749 seconds\n"
210199
]
211200
}
212201
],
@@ -217,7 +206,7 @@
217206
],
218207
"metadata": {
219208
"kernelspec": {
220-
"display_name": "C++17 (xcpp+OpenMP)",
209+
"display_name": "C++17 + OpenMP",
221210
"language": "cpp",
222211
"name": "xcpp17-omp"
223212
},

notebooks/openmp-notebooks/mandel.ipynb

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,12 @@
1010
"#include <stdio.h>\n",
1111
"#include <stdlib.h>\n",
1212
"#include <math.h>\n",
13-
"#include <omp.h>\n",
14-
"#include <clang/Interpreter/CppInterOp.h>"
13+
"#include <omp.h>"
1514
]
1615
},
1716
{
1817
"cell_type": "code",
1918
"execution_count": 2,
20-
"id": "4e037323-fbc6-43c8-a17f-6044997bf49b",
21-
"metadata": {},
22-
"outputs": [],
23-
"source": [
24-
"Cpp::LoadLibrary(\"libomp\");"
25-
]
26-
},
27-
{
28-
"cell_type": "code",
29-
"execution_count": 3,
3019
"id": "8b66f96a-14ef-4f23-8024-bcfc42b31e4e",
3120
"metadata": {},
3221
"outputs": [],
@@ -37,7 +26,7 @@
3726
},
3827
{
3928
"cell_type": "code",
40-
"execution_count": 4,
29+
"execution_count": 3,
4130
"id": "d89dd57c-fe19-4233-a33a-df9b24fae98a",
4231
"metadata": {},
4332
"outputs": [],
@@ -47,7 +36,7 @@
4736
},
4837
{
4938
"cell_type": "code",
50-
"execution_count": 5,
39+
"execution_count": 4,
5140
"id": "5c35c479-2f79-46b7-bc66-24be6b1694e0",
5241
"metadata": {},
5342
"outputs": [],
@@ -75,7 +64,7 @@
7564
},
7665
{
7766
"cell_type": "code",
78-
"execution_count": 6,
67+
"execution_count": 5,
7968
"id": "ea116fef-7d05-4e29-97a1-55c85c7241d8",
8069
"metadata": {},
8170
"outputs": [],
@@ -107,15 +96,15 @@
10796
},
10897
{
10998
"cell_type": "code",
110-
"execution_count": 7,
99+
"execution_count": 6,
111100
"id": "39cf129c-8106-4e67-a2f1-1a7fff17cd38",
112101
"metadata": {},
113102
"outputs": [
114103
{
115104
"name": "stdout",
116105
"output_type": "stream",
117106
"text": [
118-
"Area of Mandlebrot set = 3.80247750 +/- 0.00380248\n",
107+
"Area of Mandlebrot set = 5.23447313 +/- 0.00523447\n",
119108
"Correct answer should be around 1.510659\n"
120109
]
121110
}
@@ -127,7 +116,7 @@
127116
],
128117
"metadata": {
129118
"kernelspec": {
130-
"display_name": "C++17 (xcpp+OpenMP)",
119+
"display_name": "C++17 + OpenMP",
131120
"language": "cpp",
132121
"name": "xcpp17-omp"
133122
},

0 commit comments

Comments
 (0)