可以使用C ++属性替换OpenMP编译指示吗? [英] Can C++ attributes be used to replace OpenMP pragmas?

查看:93
本文介绍了可以使用C ++属性替换OpenMP编译指示吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++属性提供了一种方便的,标准化的方式,用额外的信息标记代码,以提供给编译器和/或其他工具.

C++ attributes provide a convenient and standardized way to markup code with extra information to give to the compiler and/or other tools.

使用OpenMP涉及到在源代码中添加很多#pragma omp...行(例如标记要进行并行处理的循环).这些#pragma行似乎是诸如通用属性之类的工具的最佳候选者.

Using OpenMP involves adding a lot of #pragma omp... lines into the source (such as to mark a loop for parallel processing). These #pragma lines seem to be excellent candidates for a facility such as generalized attributes.

例如,#pragma omp parallel for可能会变成[[omp::parallel(for)]].

通常不准确的cppreference.com使用这样的属性作为示例,例如此处,确认它具有至少被某人考虑过.

The often inaccurate cppreference.com uses such an attribute as an example here, which confirms it has at least been considered (by someone).

是否有OpenMP实用程序到C ++属性的映射,这些映射当前可被任何/所有主要编译器使用并支持?如果没有,是否正在计划创建一个计划?

Is there a mapping of OpenMP pragmas to C++ attributes currently available and supported by any/all of the major compilers? If not, are there any plans underway to create one?

推荐答案

这绝对是可能的,甚至是OpenMP语言委员会正在研究的东西.看看OpenMP技术报告8( https://www.openmp .org/wp-content/uploads/openmp-TR8.pdf )第36页,其中提出了通过属性使用OpenMP的语法.包含在TR8中并不能保证将其包含在5.1版中,但表明它正在被讨论.该语法主要基于原始提案中针对C ++属性所做的工作.

This is definitely a possibility and it's even something the OpenMP language committee is looking at. Take a look at OpenMP Technical Report 8 (https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf) page 36, where a syntax for using OpenMP via attributes is proposed. Inclusion in TR8 doesn't guarantee its inclusion in version 5.1, but it shows that it's being discussed. This syntax is largely based on the work done in the original proposal for C++ attributes.

如果您对此有特定的反馈意见,建议您通过OpenMP论坛(

If you have specific feedback on this, I'd encourage you to provide feedback on this via the OpenMP forum (http://forum.openmp.org/forum/viewforum.php?f=26).

这篇关于可以使用C ++属性替换OpenMP编译指示吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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