diff --git a/notebooks/openmp-notebooks/hello_world.ipynb b/notebooks/openmp-notebooks/hello_world.ipynb index 9479f962..b9bce28d 100644 --- a/notebooks/openmp-notebooks/hello_world.ipynb +++ b/notebooks/openmp-notebooks/hello_world.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "a37a13d4-fc82-496e-8f42-9e718a8c2aa0", "metadata": {}, "outputs": [ @@ -44,16 +44,24 @@ "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" ] } ], @@ -64,7 +72,7 @@ ], "metadata": { "kernelspec": { - "display_name": "C++17 (xcpp+OpenMP)", + "display_name": "C++17 + OpenMP", "language": "cpp", "name": "xcpp17-omp" }, diff --git a/notebooks/openmp-notebooks/linked_list.ipynb b/notebooks/openmp-notebooks/linked_list.ipynb index 2f5574d1..ca914de1 100644 --- a/notebooks/openmp-notebooks/linked_list.ipynb +++ b/notebooks/openmp-notebooks/linked_list.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "b16b1e8a-8831-4b8d-9d57-09deeaaa88ee", "metadata": {}, "outputs": [], @@ -55,7 +55,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "0ef8af6c-1d6f-4c68-84bc-3dd1d8092b06", "metadata": {}, "outputs": [], @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "id": "1fa0307d-fdc9-4503-95cb-1c6448791354", "metadata": {}, "outputs": [], @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "id": "03acb599-9329-49ff-8aff-c0902adb6c3c", "metadata": {}, "outputs": [], @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "id": "f2dfb41b-e55f-43c0-b7f6-546a1697acb1", "metadata": {}, "outputs": [], @@ -177,7 +177,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "id": "353e5dfd-fcae-43e6-97e3-ec98070811a1", "metadata": {}, "outputs": [ @@ -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" ] } ], @@ -206,7 +206,7 @@ ], "metadata": { "kernelspec": { - "display_name": "C++17 (xcpp+OpenMP)", + "display_name": "C++17 + OpenMP", "language": "cpp", "name": "xcpp17-omp" }, diff --git a/notebooks/openmp-notebooks/mandel.ipynb b/notebooks/openmp-notebooks/mandel.ipynb index 2d302a05..d8d19e54 100644 --- a/notebooks/openmp-notebooks/mandel.ipynb +++ b/notebooks/openmp-notebooks/mandel.ipynb @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "d89dd57c-fe19-4233-a33a-df9b24fae98a", "metadata": {}, "outputs": [], @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "5c35c479-2f79-46b7-bc66-24be6b1694e0", "metadata": {}, "outputs": [], @@ -64,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "ea116fef-7d05-4e29-97a1-55c85c7241d8", "metadata": {}, "outputs": [], @@ -96,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "id": "39cf129c-8106-4e67-a2f1-1a7fff17cd38", "metadata": {}, "outputs": [ @@ -104,7 +104,7 @@ "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" ] } @@ -116,7 +116,7 @@ ], "metadata": { "kernelspec": { - "display_name": "C++17 (xcpp+OpenMP)", + "display_name": "C++17 + OpenMP", "language": "cpp", "name": "xcpp17-omp" }, diff --git a/notebooks/openmp-notebooks/openmp-demo.ipynb b/notebooks/openmp-notebooks/openmp-demo.ipynb index 9705a587..2d6d4ca7 100644 --- a/notebooks/openmp-notebooks/openmp-demo.ipynb +++ b/notebooks/openmp-notebooks/openmp-demo.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "53fb7656-b72e-42bc-ade7-2ae2077142da", "metadata": {}, "outputs": [ @@ -42,12 +42,20 @@ "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" ] @@ -65,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "efcdfdb6-a60b-46af-8194-75ef9cc0e27f", "metadata": {}, "outputs": [ @@ -73,14 +81,22 @@ "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" ] } ], @@ -96,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "d86a9efa-ba28-4cb6-bbfc-abc00ee63506", "metadata": {}, "outputs": [ @@ -104,14 +120,22 @@ "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" @@ -137,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "id": "5557e01a-7c7d-4b54-8545-962ad11027df", "metadata": {}, "outputs": [ @@ -145,12 +169,12 @@ "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" ] } ], @@ -203,7 +227,7 @@ ], "metadata": { "kernelspec": { - "display_name": "C++17 (xcpp+OpenMP)", + "display_name": "C++17 + OpenMP", "language": "cpp", "name": "xcpp17-omp" }, diff --git a/notebooks/openmp-notebooks/pi_integral.ipynb b/notebooks/openmp-notebooks/pi_integral.ipynb index 37a44ff6..1d25c4d3 100644 --- a/notebooks/openmp-notebooks/pi_integral.ipynb +++ b/notebooks/openmp-notebooks/pi_integral.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "f3c10995-6f29-4d71-9e61-1993ca9d1cc9", "metadata": {}, "outputs": [], @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "0f84442a-d947-4860-bd3c-aeeea963b419", "metadata": {}, "outputs": [ @@ -70,18 +70,18 @@ "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" ] } @@ -93,7 +93,7 @@ ], "metadata": { "kernelspec": { - "display_name": "C++17 (xcpp+OpenMP)", + "display_name": "C++17 + OpenMP", "language": "cpp", "name": "xcpp17-omp" }, diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 280e60c0..158490dc 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -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; }