Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Alexander_D_1
New Contributor I
51 Views

How to debug a library used by a program in the offload section?

Hi!

I want to debug my library which my program uses in the offload section.

1. I tried to use library with debugging information. ​I use the following command line to build the library:

:: set environment
call D:\Intel\compilers_and_libraries\windows\bin\compilervars.bat intel64

:: compile
icl /Qmic -c -g -Wall -Werror -fpic mylib/*.cpp -lm
icl /Qmic -g -shared -o libmylib.so *.o

The size of the library tells me that the debugging information is included in it. When I'm try to debug a program (I use VS 2015 and Intell Parallel Studio 2017), the debugger does not go inside a library.

2. I tried to use the library source files for debugging, but I can't compile a program. 

Simple example:

main.cpp

#pragma offload_attribute(push, target(mic))
#include "nativelib.h"
#include <iostream>
#pragma offload_attribute(pop)

int main(int artc, char* argv[])
{
#pragma offload target(mic) 
	{
		std::cout << someFunc(3, 5);
	}
    return 0;
};

nativelib.h

#ifndef nativelib_h__
#define nativelib_h__
int someFunc(int, int);
#endif 

nativelib.cpp

#include "nativelib.h"

int someFunc(int a, int b) {
	return a + 2 * b;
};

And it lead to link error: "undefined reference to `someFunc(int, int)' ". Of course I can only use header files, but this is not a very nice option.

Please tell me what I'm doing wrong in the above options or explain another version of the debugging the library used in the offload section.

 

Best regards, Alexander.

0 Kudos
1 Reply
Alexander_D_1
New Contributor I
51 Views

So I found on Git the next project and did my project by analogy.

 In the case of the example above I had to move '#pragma offload_attribute clauses' to 'nativelib.h' :

main.cpp

#include "nativelib.h"
#include <iostream>

int main(int artc, char* argv[])
{
#pragma offload target(mic)
    {
        std::cout << someFunc(3, 5);
    }
    return 0;
};

nativelib.h

#ifndef nativelib_h__
#define nativelib_h__

#pragma offload_attribute(push, target(mic))
int someFunc(int, int);
#pragma offload_attribute(pop)

#endif
nativelib.cpp
 
#include "nativelib.h"

int someFunc(int a, int b) {
    return a + 2 * b;
};
   
 
Reply