Quantcast
Channel: Intel® Many Integrated Core Architecture
Viewing all articles
Browse latest Browse all 1347

Offload from dynamically loaded library ?

$
0
0

Hello,

I am new to programming for the Xeon Phi, and am having trouble getting explicit offload to work when the offload is done in a dynamically loaded library. The code fails at run time at the offload location, with the message

"offload error: cannot load library to the device 0 (error code 5)"

I am using C on  Scientific Linux 7, using Parallel Studio XE 2015 Update 1 Cluster Edition.  

A simple example of what I'm trying to do is below :

A basic main program which loads the dynamic library and calls the function in it :

#include <dlfcn.h>

int main()

{

        int (*fn)();

        void *lib_handle;
        lib_handle = dlopen("./hello.so", RTLD_LAZY);

        fn = dlsym(lib_handle, "sayhello");
        (fn)();
}        

This is compiled with :

icc loadsharedhello.c

And the contents of dynamic library:

#include <stdio.h>

 __attribute__((target(mic))) void MyFunction() {
         printf("Hello World from coprocessor!\n");
        fflush(0);
 }

 int sayhello () {
         printf("Hello World from host!\n");
 #pragma offload target(mic)
         {
                 MyFunction();
         }
                printf("Bye\n");
 }

This is compiled with:

icc  -shared -fpic dynamichello.c -o hello.so               

If I do the offload in the main program, it works fine. Any clues as to what I'm doing wrong ?

Thanks,

Bill


Viewing all articles
Browse latest Browse all 1347

Trending Articles