Disabling OpenMP pragma statements everywhere in my c++ project

旧街凉风 提交于 2019-11-29 16:11:34

The simplest solution is to:

  1. disable OpenMP
  2. link the OpenMP stub library functions

In case your OpenMP implementation doesn't provide stub functions, you can create your own copying from Appendix B of the standard.

Gilles

Following some dwelling around an interesting question about a non-working OpenMP code, it turns out that it is perfectly possible to get the equivalent of a stub OpenMP lib with GCC by only replacing the -fopenmp with -lgomp. I doubt it was a intended feature, but it works out of the box nonetheless.

For GCC I don't see an option to use only the stubs. Appendix B of the OpenMP standard says

    double omp_get_wtime(void)
    {
    /* This function does not provide a working
    * wallclock timer. Replace it with a version
    * customized for the target machine.
    */
    return 0.0;
    }

That's useless if you actually want the time. With GCC, either you have to write your own time function or you search for "#pragma omp" and replace it with "//#pragma omp"

Rather than changing the whole code base you could implement your own time function for GCC only. Computing time in linux :granularity and precision

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!