Cling and OpenMP

What would be the procedure to get Clang’s OpenMP working with the cling interpreter (on windows)?
I’m currently doing it this way and call my program with the -fopenmp option:

    typedef int(*myFunc_t)();

    const char* myFuncCode =
        #include "omp.h"
        #include "stdio.h" 
        #include "vector"
        extern "C" int myFunc(){

        int a, b, c;
        std::vector<float> aa(100);
        std::vector<float> bb(100);
        #pragma omp parallel for
        for (int i = 0; i < aa.size(); i+=3) {
            aa[i] = sqrt(2.0 * float(i));
            aa[i+1] = sqrt(2.0 * float(i));
            aa[i+2] = sqrt(2.0 * float(i));
            printf("thread %d\n", omp_get_thread_num());

    myFunc_t myFuncP = (myFunc_t)interp.compileFunction("myFunc", myFuncCode);

and I’m getting this error:

IncrementalExecutor::executeFunction: symbol '__kmpc_fork_call' unresolved while linking symbol 'myFunc'!
You are probably missing the definition of __kmpc_fork_call
Maybe you need to load the corresponding shared library?


You’ll probably have to build cling linking against the mp libraries.

We have no experience with OpenMP and cling. I’m happy to receive patches that add support for OpenMP to cling.

Not sure why you think building cling itself with openmp would make it work, unless it is then build with the Clang it is being built/linked against.

I’m not familiar with Windows, but presume it has the same issue as would appear on Linux: the symbols missing are from Clang’s (Intel’s) OpenMP run-time, as that is what Cling (or LLVM, rather) generates code for. Any previously linked OpenMP run-time would be the system one (on Linux/gcc that would be gomp, for example), if the system compiler was used to build Cling.

So, get the OpenMP run-time for llvm ( and explicitly load with the Windows equivalent of dlopen with RTLD_GLOBAL and you should be good to go. (There should be no problems unless Cling uses OpenMP internally, which AFAIK it doesn’t.)

Yeah but then that’s incompatible with the rest of the OpenMP libs the OP might use which is why we advocate having consistent build- and runtime. Anyway, thanks for the pointers, Wim!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.