GNU Fortran/OpenMP程序如何设置和检索stacksize-var ICV? [英] How can a GNU Fortran / OpenMP program set and retrieve the stacksize-var ICV?

查看:128
本文介绍了GNU Fortran/OpenMP程序如何设置和检索stacksize-var ICV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gfortran/libgomp构建第三方OpenMP程序,但是使用扩展来检索和设置 stacksize-var ICV时遇到了麻烦.该源代码附带了Intel Fortran( kmp_get_stacksize() kmp_set_stacksize())以及Portland Group编译器( omp_get_stack_size() omp_set_stack_size()),但是如何使用GNU Fortran和libgomp完成同一件事?

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?

我知道 OMP_STACKSIZE GOMP_STACKSIZE 环境变量,但是据我了解,实际的ICV是分开的,因此在程序启动后以编程方式设置其中之一不会影响ICV,并且只阅读一份有关该环境变量的报告,而不涉及ICV.

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.

该解决方案特定于Linux上运行的gfortran和/或libgomp是可以接受的.

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

我正在使用GCC 4.8.5中的gfortran和libgomp.

I'm using gfortran and libgomp from GCC 4.8.5.

推荐答案

该标准本身并未提供修改或检索 stacksize-var ICV的方法.因此,您注定要使用特定于实现的解决方案.

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.

现在libgomp转发由环境变量指定的值 直接连接到pthread .

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

所以您可以说libgomp将 stacksize-var 存储在 gomp_thread_attr 中.不幸的是,这似乎是 libgomp 中的本地符号,我不认为您可以合理地访问它.

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的 initialize_env ,而不是在第一个并行区域,因此实际上修改环境变量是无效的.

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.

对于非主线程,您至少可以读取实际值.尽管pthread可能使用对齐的堆栈大小,但它可能与libgomp指定的值不同.

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);

这篇关于GNU Fortran/OpenMP程序如何设置和检索stacksize-var ICV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆