<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to debug a library used by a program in the offload section? in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/How-to-debug-a-library-used-by-a-program-in-the-offload-section/m-p/1131110#M77863</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I want to debug my library which my program uses in the of&lt;SPAN style="font-size: 1em;"&gt;fload section.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;1. I tried to use library with debugging information.&amp;nbsp;​&lt;SPAN style="font-size: 1em;"&gt;&lt;SPAN style="font-size: 1em;"&gt;I use the following command line to build the library:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;:: 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
&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;The size of the library tells me that the debugging information is included in it.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;2. I tried to use the library source files for debugging, but I can't compile a program.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Simple example:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;main.cpp&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#pragma offload_attribute(push, target(mic))
#include "nativelib.h"
#include &amp;lt;iostream&amp;gt;
#pragma offload_attribute(pop)

int main(int artc, char* argv[])
{
#pragma offload target(mic) 
	{
		std::cout &amp;lt;&amp;lt; someFunc(3, 5);
	}
    return 0;
};&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;nativelib.h&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#ifndef nativelib_h__
#define nativelib_h__
int someFunc(int, int);
#endif &lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;nativelib.cpp&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "nativelib.h"

int someFunc(int a, int b) {
	return a + 2 * b;
};&lt;/PRE&gt;

&lt;P&gt;And it lead to link error: "u&lt;SPAN style="font-size: 13.008px;"&gt;ndefined reference to `someFunc(int, int)'&lt;/SPAN&gt;&amp;nbsp;". &lt;SPAN style="font-size: 13.008px;"&gt;Of course I can only use header files, but this is not a very nice option.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Best regards, Alexander.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 08:21:42 GMT</pubDate>
    <dc:creator>Alexander_D_1</dc:creator>
    <dc:date>2018-01-31T08:21:42Z</dc:date>
    <item>
      <title>How to debug a library used by a program in the offload section?</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-debug-a-library-used-by-a-program-in-the-offload-section/m-p/1131110#M77863</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I want to debug my library which my program uses in the of&lt;SPAN style="font-size: 1em;"&gt;fload section.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;1. I tried to use library with debugging information.&amp;nbsp;​&lt;SPAN style="font-size: 1em;"&gt;&lt;SPAN style="font-size: 1em;"&gt;I use the following command line to build the library:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;:: 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
&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;The size of the library tells me that the debugging information is included in it.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;2. I tried to use the library source files for debugging, but I can't compile a program.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Simple example:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;main.cpp&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#pragma offload_attribute(push, target(mic))
#include "nativelib.h"
#include &amp;lt;iostream&amp;gt;
#pragma offload_attribute(pop)

int main(int artc, char* argv[])
{
#pragma offload target(mic) 
	{
		std::cout &amp;lt;&amp;lt; someFunc(3, 5);
	}
    return 0;
};&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;nativelib.h&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#ifndef nativelib_h__
#define nativelib_h__
int someFunc(int, int);
#endif &lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;nativelib.cpp&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "nativelib.h"

int someFunc(int a, int b) {
	return a + 2 * b;
};&lt;/PRE&gt;

&lt;P&gt;And it lead to link error: "u&lt;SPAN style="font-size: 13.008px;"&gt;ndefined reference to `someFunc(int, int)'&lt;/SPAN&gt;&amp;nbsp;". &lt;SPAN style="font-size: 13.008px;"&gt;Of course I can only use header files, but this is not a very nice option.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Best regards, Alexander.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 08:21:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-debug-a-library-used-by-a-program-in-the-offload-section/m-p/1131110#M77863</guid>
      <dc:creator>Alexander_D_1</dc:creator>
      <dc:date>2018-01-31T08:21:42Z</dc:date>
    </item>
    <item>
      <title>So I found on Git the next</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-debug-a-library-used-by-a-program-in-the-offload-section/m-p/1131111#M77864</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;So I found on Git the &lt;/SPAN&gt;&lt;A href="https://github.com/gcowan/mphys-parallel/" style="font-size: 1em;"&gt;next project&lt;/A&gt;&lt;SPAN style="font-size: 1em;"&gt;&amp;nbsp;and did my project by analogy.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;In the case of the example above I had to move '#pragma offload_attribute clauses' to 'nativelib.h' :&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;main.cpp&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "nativelib.h"
#include &amp;lt;iostream&amp;gt;

int main(int artc, char* argv[])
{
#pragma offload target(mic)
    {
        std::cout &amp;lt;&amp;lt; someFunc(3, 5);
    }
    return 0;
};&lt;/PRE&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;nativelib.h&lt;/EM&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#ifndef nativelib_h__
#define nativelib_h__

#pragma offload_attribute(push, target(mic))
int someFunc(int, int);
#pragma offload_attribute(pop)

#endif
&lt;/PRE&gt;

&lt;DIV class="syntaxhighlighter  " id="highlighter_543027" style="width: 742.5px; font-size: 13.008px; color: rgb(96, 96, 96);"&gt;
	&lt;DIV class="lines" style="width: 2227.5px;"&gt;
		&lt;DIV class="line alt1"&gt;&lt;EM style="font-size: 12px; color: rgb(83, 87, 94); font-family: Arial, 宋体, Tahoma, Helvetica, sans-serif;"&gt;nativelib.cpp&lt;/EM&gt;&lt;/DIV&gt;

		&lt;DIV class="line alt1"&gt;&amp;nbsp;&lt;/DIV&gt;

		&lt;DIV class="line alt1"&gt;
			&lt;PRE class="brush:cpp;"&gt;#include "nativelib.h"

int someFunc(int a, int b) {
    return a + 2 * b;
};&lt;/PRE&gt;
		&lt;/DIV&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;

&lt;DIV class="syntaxhighlighter  " id="highlighter_901784" style="width: 742.5px; font-size: 13.008px; color: rgb(96, 96, 96);"&gt;
	&lt;DIV class="lines" style="width: 2227.5px;"&gt;
		&lt;DIV class="line alt1"&gt;
			&lt;TABLE&gt;
				&lt;TBODY&gt;
					&lt;TR&gt;
						&lt;TD class="number"&gt;&amp;nbsp;&lt;/TD&gt;
						&lt;TD class="content"&gt;&amp;nbsp;
							&lt;TABLE&gt;
								&lt;TBODY&gt;
									&lt;TR&gt;
										&lt;TD class="number"&gt;&amp;nbsp;&lt;/TD&gt;
									&lt;/TR&gt;
								&lt;/TBODY&gt;
							&lt;/TABLE&gt;
						&lt;/TD&gt;
					&lt;/TR&gt;
				&lt;/TBODY&gt;
			&lt;/TABLE&gt;
		&lt;/DIV&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:43:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-debug-a-library-used-by-a-program-in-the-offload-section/m-p/1131111#M77864</guid>
      <dc:creator>Alexander_D_1</dc:creator>
      <dc:date>2018-02-08T09:43:02Z</dc:date>
    </item>
  </channel>
</rss>

