Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions notebooks/openmp-notebooks/hello_world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,32 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "a37a13d4-fc82-496e-8f42-9e718a8c2aa0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"max threads: 8\n",
"Hello World from thread = 0 with 8 threads\n",
"Hello World from thread = 3 with 8 threads\n",
"Hello World from thread = 4 with 8 threads\n",
"Hello World from thread = 2 with 8 threads\n",
"Hello World from thread = 7 with 8 threads\n",
"Hello World from thread = 1 with 8 threads\n",
"Hello World from thread = 6 with 8 threads\n",
"Hello World from thread = 5 with 8 threads\n",
"all done, with hopefully 8 threads\n"
"max threads: 16\n",
"Hello World from thread = 0 with 16 threads\n",
"Hello World from thread = 3 with 16 threads\n",
"Hello World from thread = 13 with 16 threads\n",
"Hello World from thread = 4 with 16 threads\n",
"Hello World from thread = 12 with 16 threads\n",
"Hello World from thread = 1 with 16 threads\n",
"Hello World from thread = 14 with 16 threads\n",
"Hello World from thread = 15 with 16 threads\n",
"Hello World from thread = 8 with 16 threads\n",
"Hello World from thread = 6 with 16 threads\n",
"Hello World from thread = 11 with 16 threads\n",
"Hello World from thread = 5 with 16 threads\n",
"Hello World from thread = 7 with 16 threads\n",
"Hello World from thread = 10 with 16 threads\n",
"Hello World from thread = 9 with 16 threads\n",
"Hello World from thread = 2 with 16 threads\n",
"all done, with hopefully 16 threads\n"
]
}
],
Expand All @@ -64,7 +72,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
18 changes: 9 additions & 9 deletions notebooks/openmp-notebooks/linked_list.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "b16b1e8a-8831-4b8d-9d57-09deeaaa88ee",
"metadata": {},
"outputs": [],
Expand All @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "0ef8af6c-1d6f-4c68-84bc-3dd1d8092b06",
"metadata": {},
"outputs": [],
Expand All @@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "1fa0307d-fdc9-4503-95cb-1c6448791354",
"metadata": {},
"outputs": [],
Expand All @@ -90,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "03acb599-9329-49ff-8aff-c0902adb6c3c",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -119,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "f2dfb41b-e55f-43c0-b7f6-546a1697acb1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -177,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "353e5dfd-fcae-43e6-97e3-ec98070811a1",
"metadata": {},
"outputs": [
Expand All @@ -188,14 +188,14 @@
"Process linked list\n",
" Each linked list node will be processed by function 'processwork()'\n",
" Each ll node will compute 5 fibonacci numbers beginning with 38\n",
"Threads: 8\n",
"Threads: 16\n",
"38 : 39088169\n",
"39 : 63245986\n",
"40 : 102334155\n",
"41 : 165580141\n",
"42 : 267914296\n",
"43 : 433494437\n",
"Compute Time: 2.617225 seconds\n"
"Compute Time: 3.560749 seconds\n"
]
}
],
Expand All @@ -206,7 +206,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
12 changes: 6 additions & 6 deletions notebooks/openmp-notebooks/mandel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "d89dd57c-fe19-4233-a33a-df9b24fae98a",
"metadata": {},
"outputs": [],
Expand All @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "5c35c479-2f79-46b7-bc66-24be6b1694e0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "ea116fef-7d05-4e29-97a1-55c85c7241d8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -96,15 +96,15 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "39cf129c-8106-4e67-a2f1-1a7fff17cd38",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Area of Mandlebrot set = 3.80247750 +/- 0.00380248\n",
"Area of Mandlebrot set = 5.23447313 +/- 0.00523447\n",
"Correct answer should be around 1.510659\n"
]
}
Expand All @@ -116,7 +116,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
76 changes: 50 additions & 26 deletions notebooks/openmp-notebooks/openmp-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,28 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "53fb7656-b72e-42bc-ade7-2ae2077142da",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!Hello World!\n",
"Hello World!Hello World!\n",
"Hello World!\n",
"\n",
"Hello World!\n",
"\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n",
"Hello World!\n"
]
Expand All @@ -65,22 +73,30 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "efcdfdb6-a60b-46af-8194-75ef9cc0e27f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World! (Hello World! (Hello World! (Hello World! (34)\n",
"Hello World! (7)\n",
"0)\n",
"2Hello World! (6))\n",
"\n",
"Hello World! (Hello World! (Hello World! (Hello World! (Hello World! (12Hello World! (1)\n",
")\n",
"9)\n",
"11)\n",
"Hello World! (14)\n",
"Hello World! (13)\n",
"Hello World! (7)\n",
"Hello World! (5)\n",
"Hello World! (1)\n"
"Hello World! (6)\n",
"8)\n",
"Hello World! (3)\n",
"Hello World! (4)\n",
"0)\n",
"Hello World! (10)\n",
"Hello World! (15)\n",
"Hello World! (2)\n"
]
}
],
Expand All @@ -96,22 +112,30 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "d86a9efa-ba28-4cb6-bbfc-abc00ee63506",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World! (Hello World! (34))\n",
"Hello World! (0)\n",
"Hello World! (Hello World! (Hello World! (Hello World! (Hello World! (Hello World! (9Hello World! (8)Hello World! (\n",
"Hello World! ()\n",
"11)\n",
"1)\n",
"Hello World! (2)\n",
"Hello World! (Hello World! (1)\n",
"\n",
"7)Hello World! (\n",
"6)\n",
"3)\n",
"Hello World! (7)\n",
"Hello World! (6)\n",
"Hello World! (15)\n",
"Hello World! (10)\n",
"14)\n",
"Hello World! (5)\n",
"0)\n",
"Hello World! (4)\n",
"13)\n",
"12)\n",
"This is another message! (0)\n",
"Goodbye World! (0)\n",
"Goodbye World! (1)\n"
Expand All @@ -137,20 +161,20 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "5557e01a-7c7d-4b54-8545-962ad11027df",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Initialize a[] time: 0.588681\n",
"Initialize b[] time: 0.513927\n",
"Add arrays time: 1.58928\n",
"Average result time: 0.637053\n",
"Initialize a[] time: 0.341905\n",
"Initialize b[] time: 0.392285\n",
"Add arrays time: 0.401034\n",
"Average result time: 0.191882\n",
"Average: 5e+08\n",
"Total time: 3.33191\n"
"Total time: 1.32776\n"
]
}
],
Expand Down Expand Up @@ -203,7 +227,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
16 changes: 8 additions & 8 deletions notebooks/openmp-notebooks/pi_integral.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "f3c10995-6f29-4d71-9e61-1993ca9d1cc9",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -62,26 +62,26 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "0f84442a-d947-4860-bd3c-aeeea963b419",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Num threads available: 8\n",
"Num threads available: 16\n",
"Num threads allocated for this run: 1\n",
"pi is 3.141593 in 0.179501 seconds using 1 threads\n",
"pi is 3.141593 in 0.965932 seconds using 1 threads\n",
"\n",
"Num threads allocated for this run: 2\n",
"pi is 3.141592 in 0.184605 seconds using 2 threads\n",
"pi is 3.141593 in 0.536038 seconds using 2 threads\n",
"\n",
"Num threads allocated for this run: 3\n",
"pi is 3.141593 in 0.097145 seconds using 3 threads\n",
"pi is 3.141594 in 0.484255 seconds using 3 threads\n",
"\n",
"Num threads allocated for this run: 4\n",
"pi is 3.141593 in 0.071473 seconds using 4 threads\n",
"pi is 3.141593 in 0.480806 seconds using 4 threads\n",
"\n"
]
}
Expand All @@ -93,7 +93,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
5 changes: 4 additions & 1 deletion src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ void* createInterpreter(const Args &ExtraArgs = {}) {
)
!= ClangArgs.end())
{
Cpp::LoadLibrary("libomp");
if (!Cpp::LoadLibrary("libomp"))
{
std::cerr << "Failed to load libomp)" << std::endl;
}
}
return res;
}
Expand Down