Parallele Computing - 2 vs. 4 processor speed












2












$begingroup$


I am evaluating a code which ends with Table having ParallelEvaluate of a function XXXX[phi, theta, si]. For a grid of 225 points, a normal 2 processor laptop is taking 7 h as compared to 8.30 h by a high end Xeon 4 processor computer. CPU and memory usage for laptop and computer are about 66% vs 99% and 700MB vs 900 MB respectively. Will be thankful for any suggestion on how to improve the evaluation speed on computer. Thanks



XX1 = Table[{ParallelEvaluate[XXXX[phi, theta, si]], phi, theta, 
si}, {phi, 0, Pi/4, Pi/56}, {theta, 0, ArcCot[Cos[phi]],
ArcCot[Cos[phi]]/14}, {si, 0 Pi, 0 Pi, 0}]









share|improve this question









$endgroup$

















    2












    $begingroup$


    I am evaluating a code which ends with Table having ParallelEvaluate of a function XXXX[phi, theta, si]. For a grid of 225 points, a normal 2 processor laptop is taking 7 h as compared to 8.30 h by a high end Xeon 4 processor computer. CPU and memory usage for laptop and computer are about 66% vs 99% and 700MB vs 900 MB respectively. Will be thankful for any suggestion on how to improve the evaluation speed on computer. Thanks



    XX1 = Table[{ParallelEvaluate[XXXX[phi, theta, si]], phi, theta, 
    si}, {phi, 0, Pi/4, Pi/56}, {theta, 0, ArcCot[Cos[phi]],
    ArcCot[Cos[phi]]/14}, {si, 0 Pi, 0 Pi, 0}]









    share|improve this question









    $endgroup$















      2












      2








      2





      $begingroup$


      I am evaluating a code which ends with Table having ParallelEvaluate of a function XXXX[phi, theta, si]. For a grid of 225 points, a normal 2 processor laptop is taking 7 h as compared to 8.30 h by a high end Xeon 4 processor computer. CPU and memory usage for laptop and computer are about 66% vs 99% and 700MB vs 900 MB respectively. Will be thankful for any suggestion on how to improve the evaluation speed on computer. Thanks



      XX1 = Table[{ParallelEvaluate[XXXX[phi, theta, si]], phi, theta, 
      si}, {phi, 0, Pi/4, Pi/56}, {theta, 0, ArcCot[Cos[phi]],
      ArcCot[Cos[phi]]/14}, {si, 0 Pi, 0 Pi, 0}]









      share|improve this question









      $endgroup$




      I am evaluating a code which ends with Table having ParallelEvaluate of a function XXXX[phi, theta, si]. For a grid of 225 points, a normal 2 processor laptop is taking 7 h as compared to 8.30 h by a high end Xeon 4 processor computer. CPU and memory usage for laptop and computer are about 66% vs 99% and 700MB vs 900 MB respectively. Will be thankful for any suggestion on how to improve the evaluation speed on computer. Thanks



      XX1 = Table[{ParallelEvaluate[XXXX[phi, theta, si]], phi, theta, 
      si}, {phi, 0, Pi/4, Pi/56}, {theta, 0, ArcCot[Cos[phi]],
      ArcCot[Cos[phi]]/14}, {si, 0 Pi, 0 Pi, 0}]






      performance-tuning parallelization






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      user49535user49535

      1415




      1415






















          1 Answer
          1






          active

          oldest

          votes


















          4












          $begingroup$

          Without knowing the exact function (I assume it's something fairly long, possibly involving integrals or differential equations), I can only make the following suggestions:



          It looks like you're using exact numbers. If this is necessary for your application, then there's probably not a lot you can do, but exact numbers usually slow things down substantially. If you can, use Real numbers (just place a dot after the numbers like {phi, 0., Pi/4., Pi/56.}. If you need more precision than that but don't necessarily require the infinite precision of exact numbers, you can also do this: {phi, 0`50, Pi/4`50, Pi/56`50}. This will give you 50 digits of precision to work with which should make your final answer pretty close to the exact answer.



          The other thing I would try is:



          XX1 = ParallelTable[
          {XXXX[phi, theta, si]], phi, theta, si},
          {phi, 0, Pi/4, Pi/56},
          {theta, 0, ArcCot[Cos[phi]], ArcCot[Cos[phi]]/14},
          {si, 0 Pi, 0 Pi, 0}
          ]


          I think that ParallelTable is a better way to handle this than ParallelEvaluate. On a trial function, I see about a 100x speedup. ParallelEvaluate is simply evaluating your exact same function 4 times at each data point rather than splitting the task into multiple threads.



          If you can, combine both things for the best speedup.



          I hope this helps a bit! There are some people on here that are amazing at optimizing, perhaps they will be able to improve the speed even more. If it's possible, I would recommend posting your XXXX function unless it's insanely long.






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
            $endgroup$
            – MassDefect
            2 hours ago








          • 1




            $begingroup$
            You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
            $endgroup$
            – Lukas Lang
            2 hours ago












          • $begingroup$
            @LukasLang Oh, I see! Thanks!
            $endgroup$
            – MassDefect
            1 hour ago










          • $begingroup$
            Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
            $endgroup$
            – user49535
            22 mins ago











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "387"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189731%2fparallele-computing-2-vs-4-processor-speed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4












          $begingroup$

          Without knowing the exact function (I assume it's something fairly long, possibly involving integrals or differential equations), I can only make the following suggestions:



          It looks like you're using exact numbers. If this is necessary for your application, then there's probably not a lot you can do, but exact numbers usually slow things down substantially. If you can, use Real numbers (just place a dot after the numbers like {phi, 0., Pi/4., Pi/56.}. If you need more precision than that but don't necessarily require the infinite precision of exact numbers, you can also do this: {phi, 0`50, Pi/4`50, Pi/56`50}. This will give you 50 digits of precision to work with which should make your final answer pretty close to the exact answer.



          The other thing I would try is:



          XX1 = ParallelTable[
          {XXXX[phi, theta, si]], phi, theta, si},
          {phi, 0, Pi/4, Pi/56},
          {theta, 0, ArcCot[Cos[phi]], ArcCot[Cos[phi]]/14},
          {si, 0 Pi, 0 Pi, 0}
          ]


          I think that ParallelTable is a better way to handle this than ParallelEvaluate. On a trial function, I see about a 100x speedup. ParallelEvaluate is simply evaluating your exact same function 4 times at each data point rather than splitting the task into multiple threads.



          If you can, combine both things for the best speedup.



          I hope this helps a bit! There are some people on here that are amazing at optimizing, perhaps they will be able to improve the speed even more. If it's possible, I would recommend posting your XXXX function unless it's insanely long.






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
            $endgroup$
            – MassDefect
            2 hours ago








          • 1




            $begingroup$
            You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
            $endgroup$
            – Lukas Lang
            2 hours ago












          • $begingroup$
            @LukasLang Oh, I see! Thanks!
            $endgroup$
            – MassDefect
            1 hour ago










          • $begingroup$
            Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
            $endgroup$
            – user49535
            22 mins ago
















          4












          $begingroup$

          Without knowing the exact function (I assume it's something fairly long, possibly involving integrals or differential equations), I can only make the following suggestions:



          It looks like you're using exact numbers. If this is necessary for your application, then there's probably not a lot you can do, but exact numbers usually slow things down substantially. If you can, use Real numbers (just place a dot after the numbers like {phi, 0., Pi/4., Pi/56.}. If you need more precision than that but don't necessarily require the infinite precision of exact numbers, you can also do this: {phi, 0`50, Pi/4`50, Pi/56`50}. This will give you 50 digits of precision to work with which should make your final answer pretty close to the exact answer.



          The other thing I would try is:



          XX1 = ParallelTable[
          {XXXX[phi, theta, si]], phi, theta, si},
          {phi, 0, Pi/4, Pi/56},
          {theta, 0, ArcCot[Cos[phi]], ArcCot[Cos[phi]]/14},
          {si, 0 Pi, 0 Pi, 0}
          ]


          I think that ParallelTable is a better way to handle this than ParallelEvaluate. On a trial function, I see about a 100x speedup. ParallelEvaluate is simply evaluating your exact same function 4 times at each data point rather than splitting the task into multiple threads.



          If you can, combine both things for the best speedup.



          I hope this helps a bit! There are some people on here that are amazing at optimizing, perhaps they will be able to improve the speed even more. If it's possible, I would recommend posting your XXXX function unless it's insanely long.






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
            $endgroup$
            – MassDefect
            2 hours ago








          • 1




            $begingroup$
            You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
            $endgroup$
            – Lukas Lang
            2 hours ago












          • $begingroup$
            @LukasLang Oh, I see! Thanks!
            $endgroup$
            – MassDefect
            1 hour ago










          • $begingroup$
            Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
            $endgroup$
            – user49535
            22 mins ago














          4












          4








          4





          $begingroup$

          Without knowing the exact function (I assume it's something fairly long, possibly involving integrals or differential equations), I can only make the following suggestions:



          It looks like you're using exact numbers. If this is necessary for your application, then there's probably not a lot you can do, but exact numbers usually slow things down substantially. If you can, use Real numbers (just place a dot after the numbers like {phi, 0., Pi/4., Pi/56.}. If you need more precision than that but don't necessarily require the infinite precision of exact numbers, you can also do this: {phi, 0`50, Pi/4`50, Pi/56`50}. This will give you 50 digits of precision to work with which should make your final answer pretty close to the exact answer.



          The other thing I would try is:



          XX1 = ParallelTable[
          {XXXX[phi, theta, si]], phi, theta, si},
          {phi, 0, Pi/4, Pi/56},
          {theta, 0, ArcCot[Cos[phi]], ArcCot[Cos[phi]]/14},
          {si, 0 Pi, 0 Pi, 0}
          ]


          I think that ParallelTable is a better way to handle this than ParallelEvaluate. On a trial function, I see about a 100x speedup. ParallelEvaluate is simply evaluating your exact same function 4 times at each data point rather than splitting the task into multiple threads.



          If you can, combine both things for the best speedup.



          I hope this helps a bit! There are some people on here that are amazing at optimizing, perhaps they will be able to improve the speed even more. If it's possible, I would recommend posting your XXXX function unless it's insanely long.






          share|improve this answer











          $endgroup$



          Without knowing the exact function (I assume it's something fairly long, possibly involving integrals or differential equations), I can only make the following suggestions:



          It looks like you're using exact numbers. If this is necessary for your application, then there's probably not a lot you can do, but exact numbers usually slow things down substantially. If you can, use Real numbers (just place a dot after the numbers like {phi, 0., Pi/4., Pi/56.}. If you need more precision than that but don't necessarily require the infinite precision of exact numbers, you can also do this: {phi, 0`50, Pi/4`50, Pi/56`50}. This will give you 50 digits of precision to work with which should make your final answer pretty close to the exact answer.



          The other thing I would try is:



          XX1 = ParallelTable[
          {XXXX[phi, theta, si]], phi, theta, si},
          {phi, 0, Pi/4, Pi/56},
          {theta, 0, ArcCot[Cos[phi]], ArcCot[Cos[phi]]/14},
          {si, 0 Pi, 0 Pi, 0}
          ]


          I think that ParallelTable is a better way to handle this than ParallelEvaluate. On a trial function, I see about a 100x speedup. ParallelEvaluate is simply evaluating your exact same function 4 times at each data point rather than splitting the task into multiple threads.



          If you can, combine both things for the best speedup.



          I hope this helps a bit! There are some people on here that are amazing at optimizing, perhaps they will be able to improve the speed even more. If it's possible, I would recommend posting your XXXX function unless it's insanely long.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago









          Lukas Lang

          6,6651930




          6,6651930










          answered 3 hours ago









          MassDefectMassDefect

          84128




          84128












          • $begingroup$
            Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
            $endgroup$
            – MassDefect
            2 hours ago








          • 1




            $begingroup$
            You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
            $endgroup$
            – Lukas Lang
            2 hours ago












          • $begingroup$
            @LukasLang Oh, I see! Thanks!
            $endgroup$
            – MassDefect
            1 hour ago










          • $begingroup$
            Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
            $endgroup$
            – user49535
            22 mins ago


















          • $begingroup$
            Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
            $endgroup$
            – MassDefect
            2 hours ago








          • 1




            $begingroup$
            You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
            $endgroup$
            – Lukas Lang
            2 hours ago












          • $begingroup$
            @LukasLang Oh, I see! Thanks!
            $endgroup$
            – MassDefect
            1 hour ago










          • $begingroup$
            Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
            $endgroup$
            – user49535
            22 mins ago
















          $begingroup$
          Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
          $endgroup$
          – MassDefect
          2 hours ago






          $begingroup$
          Thanks @LukasLang ! How do you type grave accents without it interpreting them as the inline code markers? I tried backslashes before them, but that didn’t help.
          $endgroup$
          – MassDefect
          2 hours ago






          1




          1




          $begingroup$
          You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
          $endgroup$
          – Lukas Lang
          2 hours ago






          $begingroup$
          You have to increase the amount of enclosing accents: ``` `` Codewithaccents`` ```. If you need double accents, you enclose the code with three, and so on (edit: for some reason, it doesn't work in the comment section - but you can edit your answer to see how it's done)
          $endgroup$
          – Lukas Lang
          2 hours ago














          $begingroup$
          @LukasLang Oh, I see! Thanks!
          $endgroup$
          – MassDefect
          1 hour ago




          $begingroup$
          @LukasLang Oh, I see! Thanks!
          $endgroup$
          – MassDefect
          1 hour ago












          $begingroup$
          Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
          $endgroup$
          – user49535
          22 mins ago




          $begingroup$
          Thanks both of you. three points 1. I do not necessary need to use exact values of (theta, phi) if it can speed up, can use ".". 2. I tried to use ParalleleTable first, but in contrast to your experience, it took 30h/48h for 4/2 processor computer as compared to 8h/7h for ParallelEvaluate. 4 - 8 times slower. 3. How can I combine both...you mean ParallelTable[ParallelEvaluate[. ??
          $endgroup$
          – user49535
          22 mins ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189731%2fparallele-computing-2-vs-4-processor-speed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Magento 2 controller redirect on button click in phtml file

          Polycentropodidae