本文介绍了在Mac OS X上安装10.11的OpenMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得的OpenMP在Mac OSX 10.11运行,这样我就可以通过执行脚本终端的

How can I get OpenMP to run on Mac OSX 10.11, so that I can execute scripts via terminal?

我已经安装了OpenMP的: BREW安装铛-OMP

I have installed OpenMP: brew install clang-omp.

当我运行,例如:的gcc -o -fopenmp Parallel.b Parallel.c 下面前pression回报:致命错误:omp.h找不到文件

When I run, for example: gcc -fopenmp -o Parallel.b Parallel.c the following expression returns: fatal error: 'omp.h' file not found

我也尝试:酿造安装gcc --without-multilib的可惜这最终返回以下(后首次安装一些依赖):

I have also tried: brew install gcc --without-multilib but unfortunately this eventually returned the following (after first installing some dependencies):

The requested URL returned error: 404 Not Found
Error: Failed to download resource "mpfr--patch"

任何建议变通?

推荐答案


  • 安装铛-OMP

  • install clang-omp

    brew install clang-omp
    


  • 请确保你X code命令行工具

  • make sure you xcode command line tool

    xcode-select --install
    


  • 我其实有一个错误运行示例的OpenMP code,而

  • I actually had one error while running a sample openmp code

    /usr/local/opt/libiomp/include/libiomp/omp.h:139:21: error: expected ';' after top level declarator extern void   __ KAI_KMPC_CONVENTION kmp_set_stacksize_s        (size_t);
    


  • 只是删除​​一个空格,它是从文件之间__和KAI present

  • Just remove one space that is present between __ and KAI from the file

    现在使用命令

    clang-omp -fopenmp helloopenmp.c
    

    和运行以下code

    #include <omp.h>
    #include <stdio.h>
    int main() {
        #pragma omp parallel
        printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
    }
    


  • 您应该得到类似这样的输出

  • You should get output similar to this

    Hello from thread 3, nthreads 4
    Hello from thread 2, nthreads 4
    Hello from thread 0, nthreads 4
    Hello from thread 1, nthreads 4
    


  • 任职于OS X 10.11.3和日期2015年2月18日更新冲泡

  • Worked on OS X 10.11.3 and with brew update dated 18th Feb 2015

    这篇关于在Mac OS X上安装10.11的OpenMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 00:44