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











up vote
2
down vote

favorite












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


























    up vote
    2
    down vote

    favorite












    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
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      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 at 16:15









      John Bollinger

      76.6k63771




      76.6k63771
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          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',
            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








            up vote
            2
            down vote



            accepted










            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



























              up vote
              2
              down vote



              accepted










              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

























                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                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 at 18:24

























                answered Nov 19 at 18:19









                Zulan

                15k62868




                15k62868






























                     

                    draft saved


                    draft discarded



















































                     


                    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

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python