gpt4 book ai didi

C、OpenMP、更改计划类型、setenv

转载 作者:太空宇宙 更新时间:2023-11-04 02:51:10 25 4
gpt4 key购买 nike

有没有办法使用 C 中的函数更改 pragma omp for 循环中的 schedule 类型?我试图在并行语句之前执行 setenv("OMP_SCHEDULE", "guided", 1);,但我不确定它是否有效,因为我从代码中获得的时间是非常相似。我想做的是使用 for 循环更改计划类型来比较时间,将 dynamicauto 等作为setenv 函数中的字符串。

最佳答案

您可以使用 schedule(runtime) 并设置 OMP_SCHEDULE。

来自 https://computing.llnl.gov/tutorials/openMP/

RUNTIME The scheduling decision is deferred until runtime by the environment variable OMP_SCHEDULE. It is illegal to specify a chunk size for this clause.

让我只引用 Hristo Iliev 的话,因为他已经在这里说得最好了 OpenMP: for schedule

Since precompiled code could be run on various platforms it would be nice if the end user can control the scheduling. That's why OpenMP provides the special schedule(runtime) clause. With runtime scheduling the type is taken from the content of the environment variable OMP_SCHEDULE. This allows to test different scheduling types without recompiling the application and also allows the end user to fine-tune for his or her platform.

关于C、OpenMP、更改计划类型、setenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22080594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com