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
46 changes: 21 additions & 25 deletions notebooks/openmp-notebooks/hello_world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,12 @@
"outputs": [],
"source": [
"#include <stdio.h>\n",
"#include <omp.h>\n",
"#include <clang/Interpreter/CppInterOp.h>"
"#include <omp.h>"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ef1cd58a-672c-4a6f-843a-6c88fc4911f3",
"metadata": {},
"outputs": [],
"source": [
"Cpp::LoadLibrary(\"libomp\");\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c2b754ad-9553-4a42-b990-f990a9a269ed",
"metadata": {},
"outputs": [],
Expand All @@ -48,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 @@ -76,7 +72,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
31 changes: 10 additions & 21 deletions notebooks/openmp-notebooks/linked_list.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"source": [
"#include <stdlib.h>\n",
"#include <stdio.h>\n",
"#include <omp.h>\n",
"#include <clang/Interpreter/CppInterOp.h>"
"#include <omp.h>"
]
},
{
Expand All @@ -31,16 +30,6 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "8da842e1-db02-49e0-929d-4e67cbc08172",
"metadata": {},
"outputs": [],
"source": [
"Cpp::LoadLibrary(\"libomp\");"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "22f97c49-78d1-496e-ac7c-978aed95331a",
"metadata": {},
"outputs": [],
Expand All @@ -54,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "b16b1e8a-8831-4b8d-9d57-09deeaaa88ee",
"metadata": {},
"outputs": [],
Expand All @@ -66,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "0ef8af6c-1d6f-4c68-84bc-3dd1d8092b06",
"metadata": {},
"outputs": [],
Expand All @@ -85,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "1fa0307d-fdc9-4503-95cb-1c6448791354",
"metadata": {},
"outputs": [],
Expand All @@ -101,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "03acb599-9329-49ff-8aff-c0902adb6c3c",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -130,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "f2dfb41b-e55f-43c0-b7f6-546a1697acb1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -188,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "353e5dfd-fcae-43e6-97e3-ec98070811a1",
"metadata": {},
"outputs": [
Expand All @@ -199,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 @@ -217,7 +206,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
25 changes: 7 additions & 18 deletions notebooks/openmp-notebooks/mandel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@
"#include <stdio.h>\n",
"#include <stdlib.h>\n",
"#include <math.h>\n",
"#include <omp.h>\n",
"#include <clang/Interpreter/CppInterOp.h>"
"#include <omp.h>"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4e037323-fbc6-43c8-a17f-6044997bf49b",
"metadata": {},
"outputs": [],
"source": [
"Cpp::LoadLibrary(\"libomp\");"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8b66f96a-14ef-4f23-8024-bcfc42b31e4e",
"metadata": {},
"outputs": [],
Expand All @@ -37,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "d89dd57c-fe19-4233-a33a-df9b24fae98a",
"metadata": {},
"outputs": [],
Expand All @@ -47,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "5c35c479-2f79-46b7-bc66-24be6b1694e0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -75,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "ea116fef-7d05-4e29-97a1-55c85c7241d8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -107,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 @@ -127,7 +116,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "C++17 (xcpp+OpenMP)",
"display_name": "C++17 + OpenMP",
"language": "cpp",
"name": "xcpp17-omp"
},
Expand Down
Loading
Loading