How can a GNU Fortran / OpenMP program set and retrieve the stacksize-var ICV?
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
add a comment |
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
add a comment |
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
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
fortran openmp gfortran
asked Nov 19 '18 at 16:15
John Bollinger
78.6k73974
78.6k73974
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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);
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
add a comment |
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);
add a comment |
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);
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);
edited Nov 19 '18 at 18:24
answered Nov 19 '18 at 18:19
Zulan
15.2k62968
15.2k62968
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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