How can a GNU Fortran / OpenMP program set and retrieve the stacksize-var ICV?












2














I am trying to build a third-party OpenMP program with gfortran / libgomp, but I'm running into trouble with its use of extensions for retrieving and setting the stacksize-var ICV. The source comes with alternatives for Intel Fortran (kmp_get_stacksize() and kmp_set_stacksize()) and for the Portland Group compiler (omp_get_stack_size() and omp_set_stack_size()), but how can one accomplish the same thing with GNU Fortran and libgomp?



I am aware of the OMP_STACKSIZE and GOMP_STACKSIZE environment variables, but it is my understanding that the actual ICV is separate, so that programmatically setting one of these after program startup will not affect the ICV, and that reading one reports only on that environment variable, not on the ICV.



It is acceptable for the solution to be specific to gfortran and / or libgomp running on Linux.



I'm using gfortran and libgomp from GCC 4.8.5.










share|improve this question



























    2














    I am trying to build a third-party OpenMP program with gfortran / libgomp, but I'm running into trouble with its use of extensions for retrieving and setting the stacksize-var ICV. The source comes with alternatives for Intel Fortran (kmp_get_stacksize() and kmp_set_stacksize()) and for the Portland Group compiler (omp_get_stack_size() and omp_set_stack_size()), but how can one accomplish the same thing with GNU Fortran and libgomp?



    I am aware of the OMP_STACKSIZE and GOMP_STACKSIZE environment variables, but it is my understanding that the actual ICV is separate, so that programmatically setting one of these after program startup will not affect the ICV, and that reading one reports only on that environment variable, not on the ICV.



    It is acceptable for the solution to be specific to gfortran and / or libgomp running on Linux.



    I'm using gfortran and libgomp from GCC 4.8.5.










    share|improve this question

























      2












      2








      2







      I am trying to build a third-party OpenMP program with gfortran / libgomp, but I'm running into trouble with its use of extensions for retrieving and setting the stacksize-var ICV. The source comes with alternatives for Intel Fortran (kmp_get_stacksize() and kmp_set_stacksize()) and for the Portland Group compiler (omp_get_stack_size() and omp_set_stack_size()), but how can one accomplish the same thing with GNU Fortran and libgomp?



      I am aware of the OMP_STACKSIZE and GOMP_STACKSIZE environment variables, but it is my understanding that the actual ICV is separate, so that programmatically setting one of these after program startup will not affect the ICV, and that reading one reports only on that environment variable, not on the ICV.



      It is acceptable for the solution to be specific to gfortran and / or libgomp running on Linux.



      I'm using gfortran and libgomp from GCC 4.8.5.










      share|improve this question













      I am trying to build a third-party OpenMP program with gfortran / libgomp, but I'm running into trouble with its use of extensions for retrieving and setting the stacksize-var ICV. The source comes with alternatives for Intel Fortran (kmp_get_stacksize() and kmp_set_stacksize()) and for the Portland Group compiler (omp_get_stack_size() and omp_set_stack_size()), but how can one accomplish the same thing with GNU Fortran and libgomp?



      I am aware of the OMP_STACKSIZE and GOMP_STACKSIZE environment variables, but it is my understanding that the actual ICV is separate, so that programmatically setting one of these after program startup will not affect the ICV, and that reading one reports only on that environment variable, not on the ICV.



      It is acceptable for the solution to be specific to gfortran and / or libgomp running on Linux.



      I'm using gfortran and libgomp from GCC 4.8.5.







      fortran openmp gfortran






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 16:15









      John Bollinger

      78.6k73974




      78.6k73974
























          1 Answer
          1






          active

          oldest

          votes


















          2














          The standard itself does not provide a way to modify or retrieve the stacksize-var ICV. So you are doomed to use implementation-specific solutions.



          Now libgomp forwards the values specified by environment variables directly to pthread.



          So you could say that libgomp stores stacksize-var within gomp_thread_attr. Unfortunately that seems to be a local symbol in libgomp and I don't believe you can reasonably access this.



          libgomp's initialize_env is already called during library initialization, not at the first parallel region, so modifying the environment variable is in fact not effective.



          For the non-master threads you can at least read the actual value. Although pthread may use an aligned stack size, so it may not be the same value that libgomp specifies.



          size_t stacksize;
          pthread_attr_t attr;
          // TODO check return values
          pthread_getattr_np(pthread_self(), &attr);
          pthread_attr_getstacksize(&attr, &stacksize);





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53378713%2fhow-can-a-gnu-fortran-openmp-program-set-and-retrieve-the-stacksize-var-icv%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









            2














            The standard itself does not provide a way to modify or retrieve the stacksize-var ICV. So you are doomed to use implementation-specific solutions.



            Now libgomp forwards the values specified by environment variables directly to pthread.



            So you could say that libgomp stores stacksize-var within gomp_thread_attr. Unfortunately that seems to be a local symbol in libgomp and I don't believe you can reasonably access this.



            libgomp's initialize_env is already called during library initialization, not at the first parallel region, so modifying the environment variable is in fact not effective.



            For the non-master threads you can at least read the actual value. Although pthread may use an aligned stack size, so it may not be the same value that libgomp specifies.



            size_t stacksize;
            pthread_attr_t attr;
            // TODO check return values
            pthread_getattr_np(pthread_self(), &attr);
            pthread_attr_getstacksize(&attr, &stacksize);





            share|improve this answer




























              2














              The standard itself does not provide a way to modify or retrieve the stacksize-var ICV. So you are doomed to use implementation-specific solutions.



              Now libgomp forwards the values specified by environment variables directly to pthread.



              So you could say that libgomp stores stacksize-var within gomp_thread_attr. Unfortunately that seems to be a local symbol in libgomp and I don't believe you can reasonably access this.



              libgomp's initialize_env is already called during library initialization, not at the first parallel region, so modifying the environment variable is in fact not effective.



              For the non-master threads you can at least read the actual value. Although pthread may use an aligned stack size, so it may not be the same value that libgomp specifies.



              size_t stacksize;
              pthread_attr_t attr;
              // TODO check return values
              pthread_getattr_np(pthread_self(), &attr);
              pthread_attr_getstacksize(&attr, &stacksize);





              share|improve this answer


























                2












                2








                2






                The standard itself does not provide a way to modify or retrieve the stacksize-var ICV. So you are doomed to use implementation-specific solutions.



                Now libgomp forwards the values specified by environment variables directly to pthread.



                So you could say that libgomp stores stacksize-var within gomp_thread_attr. Unfortunately that seems to be a local symbol in libgomp and I don't believe you can reasonably access this.



                libgomp's initialize_env is already called during library initialization, not at the first parallel region, so modifying the environment variable is in fact not effective.



                For the non-master threads you can at least read the actual value. Although pthread may use an aligned stack size, so it may not be the same value that libgomp specifies.



                size_t stacksize;
                pthread_attr_t attr;
                // TODO check return values
                pthread_getattr_np(pthread_self(), &attr);
                pthread_attr_getstacksize(&attr, &stacksize);





                share|improve this answer














                The standard itself does not provide a way to modify or retrieve the stacksize-var ICV. So you are doomed to use implementation-specific solutions.



                Now libgomp forwards the values specified by environment variables directly to pthread.



                So you could say that libgomp stores stacksize-var within gomp_thread_attr. Unfortunately that seems to be a local symbol in libgomp and I don't believe you can reasonably access this.



                libgomp's initialize_env is already called during library initialization, not at the first parallel region, so modifying the environment variable is in fact not effective.



                For the non-master threads you can at least read the actual value. Although pthread may use an aligned stack size, so it may not be the same value that libgomp specifies.



                size_t stacksize;
                pthread_attr_t attr;
                // TODO check return values
                pthread_getattr_np(pthread_self(), &attr);
                pthread_attr_getstacksize(&attr, &stacksize);






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 19 '18 at 18:24

























                answered Nov 19 '18 at 18:19









                Zulan

                15.2k62968




                15.2k62968






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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.


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





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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.


                    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%2fstackoverflow.com%2fquestions%2f53378713%2fhow-can-a-gnu-fortran-openmp-program-set-and-retrieve-the-stacksize-var-icv%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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    Npm cannot find a required file even through it is in the searched directory